-
Notifications
You must be signed in to change notification settings - Fork 0
/
snake.h
52 lines (51 loc) · 1.04 KB
/
snake.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
#ifndef SNAKE_H
#define SNAKE_H
#include<QRect>
#include<QTimer>
#include<QTime>
#include<QTimerEvent>
#include<QObject>
class Snake:public QObject
{
Q_OBJECT
public:
Snake();
~Snake();
int snaketime(){return time;}
void init_Snake();
void isHit();
void isEat();
int returnscore(){return score;}
QRect returnhead(){return SnakeRect[0];}
QRect* returnbody(){return SnakeRect;}
QRect returntail(){return SnakeRect[Snakelen-1];}
int returnlens(){return Snakelen;}
int direction;
int notletthesnakegoback;
void rebegin();
void reset();
bool returntrulyover(){return istrulyover;}
bool isRun;
bool isOver;
bool isPause;
bool istrulyover;
Snake &operator=(const Snake &snake);
public slots:
void Snake_update();
protected:
void timerEvent(QTimerEvent *event);
int x;
int y;
int x1;
int x2;
int y1;
int y2;
int time;
int count;
QRect *SnakeRect;
QRect SnakeHeard;
int Snakelen;
int score;
QTimer *timer;
};
#endif // SNAKE_H