CNode,擁有顏色、轉向座標鏈表CSnake 管理節點鏈表與遊戲邏輯CWnd 建立隱藏窗口處理計時器
enum Direction { UP=1, DOWN, LEFT, RIGHT, Error };
struct Data { Direction dirt; CPoint pot; };
typedef CList<Data, Data&> DirectionList;
class CNode : public CObject {
CPoint m_Point;
Direction m_CurrentDirection;
DirectionList m_List; // 轉向點鏈表
COLORREF m_Color;
int m_nColorIndex;
friend class CSnake;
public:
void SetDirection(CPoint);
COLORREF GetColor();
void AddDirection(Data*);
Data* RemoveHead();
void Change(CPoint&); // 移動並檢查轉向
// ... 其他訪問器
};
LoadLibrary 加載CSnake
E-mail: Error_110@163.com,歡迎指導交流。