-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgamescene.h
51 lines (40 loc) · 966 Bytes
/
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
#ifndef GAMESCENE_H
#define GAMESCENE_H
#include <QObject>
#include <QGraphicsScene>
#include "game.h"
#include <QGraphicsPixmapItem>
#include <QTimer>
#include <QElapsedTimer>
class QSoundEffect;
class GameScene : public QGraphicsScene
{
Q_OBJECT
public:
GameScene(QObject* parent = nullptr);
void start();
void stop();
void setMuted(bool val);
private:
void renderScene();
Game game;
QGraphicsPixmapItem* m_background, *m_tiles, *m_frame;
const float timePerFrame;
QTimer *timer;
QSoundEffect* m_hitSFX;
bool m_isMuted;
void drawScore();
void drawGameState();
void drawActiveFigure();
void moveFigure();
void drawBackground();
void rotateFigure();
protected:
virtual void keyPressEvent(QKeyEvent *event) override;
virtual void keyReleaseEvent(QKeyEvent *event) override;
private slots:
void update();
signals:
void goToMenuActivated();
};
#endif // GAMESCENE_H