-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.h
80 lines (71 loc) · 2.08 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
70
71
72
73
74
75
76
77
78
79
80
#ifndef GAME_H
#define GAME_H
#include <QWidget>
#include <QVector>
#include "skystar.h"
#include "player.h"
#include "enemy.h"
#include "explosion.h"
#include "wave.h"
#include "asteroid.h"
#include "explosion.h"
#include <memory>
namespace Ui {
class Game;
}
class Game : public QWidget
{
Q_OBJECT
public:
enum class State{Menu, Play, PlayerHurt, GameOver, GetReady, YouWin};
enum class Menu{NewGame,Exit};
void changeState(State state);
static Game& getInstance();
std::shared_ptr<Player>& getPlayer();
QVector<std::shared_ptr<Shot>>& getShots();
QVector<std::shared_ptr<Asteroid>>& getAsteroids();
long int& getCounter();
void execute();
void executePlay();
void executePlayerHurt();
void executeGetReady();
void executeYouWin();
void executeGameOver();
void executeMenu();
void resolveCollisions();
void nextWave();
void makeDemage(std::shared_ptr<PhysicalObject> object1, std::shared_ptr<PhysicalObject> object2);
std::shared_ptr<Explosion> makeExplosion(std::shared_ptr<PhysicalObject> object1, std::shared_ptr<PhysicalObject> object2);
void paintEvent(QPaintEvent *event);
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event);
void closeEvent(QCloseEvent *event);
bool loadGame();
bool saveGame() const;
void newGame();
void read(const QJsonObject &json);
void write(QJsonObject &json) const;
private:
Ui::Game *ui;
explicit Game(QWidget *parent = nullptr);
Game(Game const&) = delete;
~Game();
Game& operator= (Game const&) = delete;
long int COUNTER;
unsigned int GETREADY;
QTimer *timer;
QFont emulogic;
std::shared_ptr<Player> player;
QVector<std::shared_ptr<Player>> players;
QVector<std::shared_ptr<SkyStar>> sky;
QVector<std::shared_ptr<Wave>> waves;
QVector<std::shared_ptr<Enemy>> enemies;
QVector<std::shared_ptr<Explosion>> explosions;
QVector<std::shared_ptr<Shot>> shots;
QVector<std::shared_ptr<Asteroid>> asteroids;
QVector<std::shared_ptr<Drawed>> drawable;
QVector<std::shared_ptr<PhysicalObject>> physical;
State state = State::Menu;
Menu menuItem;
};
#endif // GAME_H