-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnake.h
44 lines (40 loc) · 1.26 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
#ifndef SNAKE_H
#define SNAKE_H
#include <QGraphicsItem>
#include <QRectF>
#include "constant.h"
#include <qiterator.h>
class Gamecontroller;
class QLCDNumber;
class Snake:public QGraphicsItem
{
friend class Gamecontroller;
public:
typedef enum {NoMove,MoveLeft='a',MoveRight='d',MoveUp='w',MoveDown='s'} Direction;
typedef enum {NOEFFECT,SLOWDOWN,SPEEDUP,THROUGHWALL} Specialeffect;
Snake(int &mark,QLCDNumber &monitor,Gamecontroller &ctrl,int x=0,int y=0,QColor color=DEFAULT_COLOR,int le=DEFAULT_LENGTH);
QRectF boundingRect() const;
void paint(QPainter *painter,const QStyleOptionGraphicsItem *option,QWidget *widget);
void advance(int phase);
QPainterPath shape() const;
void handleCollision();
void setMoveDirection(Direction direction);
void reshape();
void ResetColor(){ColorOfSnake=DEFAULT_COLOR;effect=NOEFFECT;}
void moveBackward();
void randommove(QPoint newPos);
void autoforage();
Gamecontroller &ctrl;
QList<QPoint> body;
Direction moveDirection;
int growing;
int LengthOfSnake;
int &score;
QLCDNumber &monitor;
QPoint PosOfSnake;
QColor ColorOfSnake;
Specialeffect effect;
bool immortal;
bool alive;
};
#endif // SNAKE_H