-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vehicle.h
41 lines (40 loc) · 1.46 KB
/
Vehicle.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
#ifndef VEHICLE_H
#define VEHICLE_H
#include<QGraphicsPixmapItem>
#include<GameWindow.h>
#include<QObject>
/**
* @brief Moves across the game's scene.
* \details Player's goal is to avoid instances of this class.
*/
class Vehicle: public QObject, public QGraphicsPixmapItem //inherits from QObject so that it can connect to slots
{
Q_OBJECT
int speed; /**< Speed of the Vehicle class instance.*/
int position/**< Y - position on the game's scene, where Vehicle class instance will be spawned.*/;
GameWindow::laneDirection direction /**< Decides which way the Vehicle class instance will move.*/;
public:
/**
* @brief Vehicle constructor.
* \details Draws random pixmap for the Vehicle class instance and connects slot Vehicle::move() to GameWindow::timer.
* @param dir Decides which way the Vehicle class instance will move.
* @param posY - y coordinate on the game's scene, where Vehicle class instance will be spawned.
* @param speed Speed of the Vehicle class instance.
*/
Vehicle(GameWindow::laneDirection dir, int posY, int speed);
/**
* @brief Return the speed of a Vehicle class instance.
* @return Speed of a Vehicle class instance.
*/
int getVehicleSpeed()
{
return speed;
}
public slots:
/**
* @brief Moves a Vehicle class instance with a given speed.
* \details Direction of the movement depends on the direction member.
*/
void move();
};
#endif // VEHICLE_H