⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 snake.h

📁 这是基于QT编写的一个linux下的贪吃蛇游戏。
💻 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 + -