-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lane.h
68 lines (63 loc) · 2.7 KB
/
Lane.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
#ifndef LANE_H
#define LANE_H
#include<GameWindow.h>
#include<Vehicle.h>
/**
* @brief Manages the instances of Vehicle class.
*/
class Lane: public QObject, public QGraphicsPixmapItem
{
Q_OBJECT
static GameWindow * gameWindow; /**< Pointer to the GaneWindow class instance that generated the Lane class instance.*/
static int minSpeed; /**< Minimal speed of the Vehicle class instances generated on the Lane class instance.*/
static int maxSpeed; /**< Maximal speed of the Vehicle class instances generated on the Lane class instance.*/
int lanePosition; /**< Y position of the Lane on the gameWindow->scene.*/
/**
* @brief Used to draw random speed of the generated instances of Vehicle class.
* @param minSpeed Minimal speed
* @param maxSpeed Maximal speed
* @return Random speed assigned to new Vehicle class instance
*/
int randomSpeed(int minSpeed, int maxSpeed);
QList<Vehicle *> currentVehicles; /**< List of all Vehicle class instances on Lane class instance.*/
std::unique_ptr<QTimer> deleteTimer; /**< Holds a QTimer.
\details Used by Lane class instance as a signal connected to slot Lane::deleteOutOfScene()*/
GameWindow::laneDirection direction; /**< Direction of Vehicle class instances on the Lane class instance.*/
public:
/**
* @brief Lane constructor.
* \details Lane class members are initialized and slots Lane::deleteOutOfScene() and Lane::spawn() are connected to its signals.
* @param game GameWindow class instance that the Lane class instance is assigned to.
* @param dir Direction of the Vehicle class instances' movement.
* @param lane Lane class instance position on the gameWindow->scene.
*/
Lane(GameWindow* game, GameWindow::laneDirection dir, int lane);
/**
* @brief Returns the Y-position of the Lane class instance on the gameWindow->scene.
* @return Y-position of the Lane class instance on the gameWindow->scene.
*/
int getLanePosition()
{
return lanePosition;
}
/**
* @brief Increments minimal and maximal speed of the Vehicle class instances
* generated by the Lane class instance. It also increases the spawn frequency of these Vehicles.
*/
static void increaseDifficulty();
/**
* @brief Resets minimal speed,maximal speed and spawn frequency to its initial values.
*/
static void resetDifficulty();
public slots:
/**
* @brief Generates Vehicle class instances moving with random speed.
*/
void spawn();
/**
* @brief Checks whether Vehicle class instances have left the gameWindow->scene's visible area.
* If so, these instances are deleted.
*/
void deleteOutOfScene();
};
#endif // LANE_H