-
Notifications
You must be signed in to change notification settings - Fork 0
/
multiplesnake.h
53 lines (40 loc) · 995 Bytes
/
multiplesnake.h
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
#ifndef MUTIPLESNAKE_H
#define MUTIPLESNAKE_H
#include "snake.h"
class multipleSnake: public Snakegame
{
public:
multipleSnake(int n=1);
protected:
void timerEvent(QTimerEvent *) override;
void render(QPainter *p) override;
void keyPressEvent(QKeyEvent *e) override;
void gameover(int n);
void handleCollisions();
bool foodhideinwall();
void restart();
private:
int numOfPlayer;
int m_timerId;
int score[4];
QList<QRect> snake[4];
int length[4];//蛇长
int x[4];//蛇头横坐标
int y[4];//蛇头纵坐标
struct Food{
int a;//果实横坐标
int b;//果实纵坐标
int kind;//果实种类
Food(int x=0, int y=0, int k=1){
a = x;
b = y;
kind = k;
}
};
Food food[4];
Food extrafood[50];
int numofExtraFood;
int deadPlayer;//死亡玩家数
int direction[4]={4, 4, 4, 4};//方向标记物
};
#endif // MUTIPLESNAKE_H