snake.h

来自「贪吃蛇的源代码..比较简单,就不介绍了...」· C头文件 代码 · 共 54 行

H
54
字号
#pragma once
#include "Global.h"
#include "object.h"
#include <vector>
using std::vector;

enum DIR {UP, DOWN, LEFT, RIGHT};
//================================
//Class Node
//================================
class Node  :
    virtual public Object
{
private:
    USHORT m_x,m_y;
    DIR m_dir;
public:
    Node(void);
    Node(USHORT x, USHORT y);
    //Node(const Node& N);
    virtual ~Node(void);
    USHORT  GetX(void) const;
    void    SetX(USHORT x);
    USHORT  GetY(void) const;
    void    SetY(USHORT y);
    void    GetXY(USHORT& x, USHORT& y) const;
    void    SetXY(USHORT x, USHORT y);
    operator    char() const;
    DIR     GetDir(void) const;
    void    SetDir(DIR dir);
};

//================================
//Class Snake
//================================
class Snake :
    virtual public Object
{
private:
    vector<Node> m_body;
public:
    Snake(void);
    virtual ~Snake(void);
    bool isInBody(USHORT x, USHORT y);

#ifdef DEBUG
public:
#if (DEBUG==1)
    void print(void);
#endif //end #if(DEBUG==1)
#endif

};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?