-
Notifications
You must be signed in to change notification settings - Fork 0
/
minestormgame.h
103 lines (85 loc) · 2.22 KB
/
minestormgame.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#ifndef MINESTORMGAME_H
#define MINESTORMGAME_H
#include "game.h"
#include <vector>
#include<tuple>
#include "spaceship.h"
#include "mine.h"
#include "explosion.h"
/**
* @brief La classe MineStormGame gère l'ensemble du jeu et centralise les actions
*/
class MineStormGame : public Game {
Q_OBJECT
public:
/**
* @brief Constructeur
* @param size : taille de la zone de jeu
* @param parent : QWidget parent
*/
MineStormGame(const QSize &size, QObject *parent = nullptr);
/**
* @brief draw
* @param painter
*/
virtual void draw(QPainter &painter);
/**
* @brief Appelée lorsqu'une touche est appuyée
* @param key : touche pressée
*/
void keyPressed( int key );
/**
* @brief Appelée lorsqu'une touche est relâchée
* @param key : touche relâchée
*/
void keyReleased( int key );
/**
* @brief Permet de générer des mines disposées aléatoirement
* @param small : Nombre de petites mines
* @param medium : Nombre de mines moyennes
* @param big : Nombre de grandes mines
*/
void generateMines(int small, int medium, int big);
/**
* @brief Décrémente le compteur de vie si il en reste, sinon Game Over
*/
void looseLife();
private:
/**
* @brief Initialise le jeu
*/
void initialize();
/**
* @brief Rajoute de mines (appelé toutes les 30 secondes)
*/
void repop();
/**
* @brief Ajoute une Bullet à l'affichage
*/
void fire();
/**
* @brief Renvoie un point aléatoire à l'écran
* @return QPoint aléatoire
*/
QPoint getRandomPoint() const;
/**
* @brief Dessine les vies restantes à l'écran
* @param painter
*/
void drawLives(QPainter &painter) const;
SpaceShip *_ship;
std::vector<ShipBullet> _bullets;
std::vector<Mine> _mines;
std::vector<Explosion> _explosions;
int _livesLeft;
bool _leftKeyDown;
bool _rightKeyDown;
bool _upKeyDown;
bool _downKeyDown; //Touche de test, à enlever dans la version finale
bool _spaceKeyDown;
int _fireCounter;
int _accelerationFactor;
int _repopCounter;
int _cooldownRespawn;
};
#endif // MINESTORMGAME_H