From 98ba22e7064db57316dfff1ae127feb3dceeb73e Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Thu, 31 Jul 2014 13:58:22 +0200 Subject: Initial commit --- source/logic/Car.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 source/logic/Car.h (limited to 'source/logic/Car.h') diff --git a/source/logic/Car.h b/source/logic/Car.h new file mode 100644 index 0000000..4b8d16c --- /dev/null +++ b/source/logic/Car.h @@ -0,0 +1,57 @@ +#ifndef CAR_H +#define CAR_H + +#include +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 -- cgit v1.2.3