-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgamescene.h
69 lines (55 loc) · 1.81 KB
/
gamescene.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
#ifndef GAMESCENE_H
#define GAMESCENE_H
#include <QVariant>
// #include "qtypes.h"
#include "qgraphicsscene.h"
#include "entities.h"
class gameScene: public QGraphicsScene
{
Q_OBJECT
private:
float laneFraction;
float laneDividerFraction;
float greeneriesFraction;
quint16 roadBoundary1, roadBoundary2;
quint16 divider1, divider2;
quint16 sceneWidth;
quint32 displacement_per_frame;
uint fps;
quint16 sceneHeight;
QVector<QPixmap> entities; // List of available entities
QVector<QPixmap> trees;
QList<Obstacles *> activeObstacles; // List of currently spawned obstacles
QList<Greeneries *> activeTrees;
QList<QGraphicsLineItem*> dividerLeft;
QList<QGraphicsLineItem*> dividerRight;
QGraphicsTextItem *score;
QGraphicsTextItem *lives;
QHash<Region, qreal> map;
quint32 speed;
QString livesHtml = QString("<div style='color: white; font-size: 20px; font-weight: bold;'>"
"Lives: <span style='color: red'> %1 </span>"
"</div>");
QString scoreHtml = QString("<div style='color: white; font-size: 20px;'>"
"Score: <b>%1</b>"
"</div>");
void updateLives(int lives);
void updateScore(int );
public:
gameScene(int w, int h, int fps, QVector<QPixmap> , QVector<QPixmap>);
void drawRoadBoundaries();
void drawRoadStrips();
void drawGreeneries();
void addImage(const QString &filePath, int x, int y);
void renderMainCar(MainPlayer&);
void renderObstacles(MainPlayer&);
void renderGreeneries();
void spawnObstacle();
QRectF getRoadBoundary() const;
void updateRoadStrips();
void spawnTrees();
signals:
void updateLife(int life);
void gameOver();
};
#endif // GAMESCENE_H