📄 snake.h
字号:
#include <iostream>
#include <string>
#include <vector>
using std::string;
using std::cin;
using std::cout;
using std::endl;
using std::vector;
class Pos {
public:
int x;
int y;
};
class Body {
public:
Pos pos;
Body *next;
Body *prev;
};
class Foods {
vector<Pos> food;
public:
void init( int num, int x_max, int x_min, int y_max, int y_min );
int getX( int index );
int getY( int index );
};
class Snake {
private:
Body *head;
Body *tail;
string direction;
string directionOld;
public:
Snake();
~Snake();
void move();
void turn( string direction );
void grow();
Body* getSnakeTail();
Body* getSnakeHead();
void display();
bool biteSelf();
int length();
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -