forked from abdallahabdelaziz1/PacmanGame
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayer.h
More file actions
48 lines (46 loc) · 1.35 KB
/
Copy pathplayer.h
File metadata and controls
48 lines (46 loc) · 1.35 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
#ifndef PLAYER_H
#define PLAYER_H
#include <QObject>
#include <QGraphicsPixmapItem>
#include <QPixmap>
#include <QString>
#include <QTimer>
#include <QList>
#include <QDebug>
#include<QPair>
class player : public QObject, public QGraphicsPixmapItem
{
Q_OBJECT
private:
const int TotalRows=31;
const int TotalColumns=28;
const int spawnrow = 23;
const int spawncol = 13;
int row=23;
int col=13;
char direct = 'R';
char tempDirect = 'R';
int blockDim = 20;
int margin = 30;
int speed = 2; //need to be a divisor of blockDim so that rowPerSpeed is an integer.
int Xpos = blockDim*col+margin;
int Ypos = blockDim*row+margin;
int tempRow;
int tempCol;
QPixmap pacman;
int** boardData;
QTimer* mouthanim;
int frame = 0;
public:
player(int** temp); //takes the game board as an argument
QPair<int, int> getCoordinate();
void move(); //updates pacman position accdording to the value of direct
void changedir(char dir); //changes direction and image. Takes 'U', 'D', 'R' or 'L' as an argument;
void reset(); //returns pacman to spawn
void startanim();
void endanim();
int getdir(); //returns pacman direction (0->up, 1->down, 2->right, 3->left)
private slots:
void movemouth();
};
#endif // PLAYER_H