summaryrefslogtreecommitdiff
path: root/source/logic/Car.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/logic/Car.h')
-rw-r--r--source/logic/Car.h57
1 files changed, 57 insertions, 0 deletions
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 <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