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/CollisionDetector.h | 75 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 source/logic/CollisionDetector.h (limited to 'source/logic/CollisionDetector.h') diff --git a/source/logic/CollisionDetector.h b/source/logic/CollisionDetector.h new file mode 100644 index 0000000..294852d --- /dev/null +++ b/source/logic/CollisionDetector.h @@ -0,0 +1,75 @@ +#ifndef COLLISIONDETECTOR_H +#define COLLISIONDETECTOR_H + +#include +using namespace std; + +#include "../logic/PlayerCar.h" +#include "../logic/EnemyCar.h" +#include "../logic/Checkpoint.h" +#include "../logic/Rock.h" +#include "../logic/Smokescreen.h" + +/** +* @brief Object for handling collisions between GameObjects. +* +* Collisions between all relevant objects are checked and the appropriate methods on the GameObjects +* are called when a collision occurs. +* +* @author Justin Wernick +* @author David Schneider +*/ +class CollisionDetector +{ + public: + /** + * @brief Checks for collisions between all relevant pairs of objects, and calls the relevant collision function if one is found. + * + * A collision occurs if the distance between two object's x values is less than 1, + * and the distance between their y values is also less than 1. + * + * @param [in,out] players List of PlayerCars, that can collide with EnemieCars, Checkpoints, or Rocks. + * @param [in,out] enemies List of EnemyCars, that can collide with PlayerCars, or Smokescreens. + * @param [in,out] checkpoints List of Checkpoints, that can collide with PlayerCars. + * @param [in,out] rocks List of Rocks, that can collide with PlayerCars. + * @param [in,out] smokescreens List of Smokescreens, that can collide with EnemyCars. + */ + void checkCollisions(list& players, list& enemies, list& checkpoints, list& rocks, list& smokescreens); + + //assignment and copy constructors have been left with the compiler generated versions + + private: + /** + * @brief Collision between a PlayerCar and a Checkpoint. + * + * @param [in,out] player PlayerCar involved in the collision. + * @param [in,out] checkpoint Checkpoint involved in the collision. + */ + void collision(PlayerCar& player, Checkpoint& checkpoint); + + /** + * @brief Collision between a PlayerCar and an EnemyCar. + * + * @param [in,out] player PlayerCar involved in the collision. + * @param [in,out] enemy EnemyCar involved in the collision. + */ + void collision(PlayerCar& player, EnemyCar& enemy); + + /** + * @brief Collision between a PlayerCar and a Rock. + * + * @param [in,out] player PlayerCar involved in the collision. + * @param [in,out] rock Rock involved in the collision. + */ + void collision(PlayerCar& player, Rock& rock); + + /** + * @brief Collision between an EnemyCar and a Smokescreen. + * + * @param [in,out] enemy EnemyCar involved in the collision. + * @param [in,out] smokescreen Smokescreen involved in the collision. + */ + void collision(EnemyCar& enemy, Smokescreen& smokescreen); +}; + +#endif // COLLISIONDETECTOR_H -- cgit v1.2.3