-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSnake_first.h
More file actions
61 lines (42 loc) · 1.1 KB
/
Snake_first.h
File metadata and controls
61 lines (42 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef SNAKE_H //玩家一
#define SNAKE_H
#include"Food.h"
class Snake_first
{
public:
Snake_first(Wall& wall, Food& food); //构造函数
enum //定义枚举类型,分别代表上下左右方向
{
UP = 'w',
DOWN='s',
LEFT='a',
RIGHT='d',
};
struct point //定义结构体,用来节点储存位置,以及指向下一位置的指针;节点代表蛇身
{
int x;
int y;
point* next;
};
void InitSnake(); //初始化蛇
bool Move(char key); //蛇的移动
void DestoryPoint(); //销毁节点
void AddPoint(int , int); //增加节点
void DeletePoint(); //删除节点
int Getsleeptime(); //获得延迟时间
int Countlist(); //计算蛇身长度
void Resetscore(); //重置得分
int Getscore(); //获取得分
int Getability(); //查看是否具有穿墙能力
void Resetability(); //重置穿墙能力
clock_t start; //记录时间
int difficulty; //记录难度等级
private:
point* Head; //代表蛇头
Wall& wall_;
Food& food_;
int score; //记录得分
int ability; //表示蛇是否具有穿墙能力
};
#endif // !SNAKE_FIRST_H
#pragma once