summaryrefslogtreecommitdiff
path: root/source/logic/Car.h
blob: 4b8d16c6a2e77c23b16e35b8ca135d32c1af531b (plain)
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
#ifndef CAR_H
#define CAR_H

#include <cmath>
using namespace std;

#include "../presentation/BitmapStore.h"
#include "../logic/GameObject.h"
#include "../logic/MazeMath.h"

/**
* @brief GameObject that moves through the maze and changes direction.
*
* Should not be instantiated directly, but rather instantiated through one of the subclasses,
* PlayerCar or EnemyCar.
*
* @author Justin Wernick
* @author David Schneider
*/
class Car : public GameObject
{
    public:
        /**
        * @brief Creates a Car at the given position, with the given image, facing in the given direction.
        *
        * @param [in] x x coordinate of initial position.
        * @param [in] y y coordinate of initial position.
        * @param [in] image Bitmap to be drawn on the screen to represent the car.
        * @param [in] facing Direction in which the Car is initially facing.
        */
        Car(double x, double y, BitmapStore::Image image, Maze::Direction facing);

        //assignment and copy constructors have been left with the compiler generated versions

        /**
        * @brief Function to access the current speed of the car.
        *
        * @return The current speed of the car, in pixels per update.
        */
        double speed() const;

    protected:
        /**
        * @brief Moves the car by its current speed in the direction of its facing.
        *
        * Only moves along the x or y axis, and snaps to the grid in the other direction.
        * Does not allow movement through solid parts of the maze.
        *
        * @param [in] maze The maze in which the Car is moving, confining its movements.
        */
        void move(const Maze& maze);

        double _speed; ///< The current speed that the Car is moving at.
        static const double _baseSpeed = 0.1; ///< The speed that a Car moves at in normal conditions.
};

#endif // CAR_H