-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGame.h
executable file
·69 lines (48 loc) · 1.21 KB
/
Game.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#pragma once
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsLineItem>
#include <QTimer>
#include <QElapsedTimer>
#include <QSound>
#include "Pacman.h"
#include "Level.h"
class Game : public QGraphicsView
{
Q_OBJECT
enum game_state{READY, RUNNING, PAUSE, GAME_OVER};
private:
static Game* uniqueInstance; // Singleton
Game(QGraphicsView *parent=0); // Singleton
QGraphicsScene* _scene;
Pacman* _player;
QTimer _engine;
game_state _state;
QGraphicsPixmapItem* _ready_txt;
QGraphicsPixmapItem* _paused_txt;
QGraphicsPixmapItem* _gameover_txt;
void init();
protected:
virtual void keyPressEvent(QKeyEvent *e);
public:
// singleton
static Game* instance();
// getters
QGraphicsScene* scene(){return _scene;}
Pacman* player(){return _player;}
public slots:
// advance game / next frame
void advance();
// tooglers
void tooglePause();
// reset game
void reset();
// start game
void start();
// game over
void gameover();
// ghost state updates
void setGhostsVisible(bool visible);
// game events
void ballEat(bool big);
};