diff options
author | Justin Worthe <justin.worthe@entelect.co.za> | 2014-07-31 13:58:22 +0200 |
---|---|---|
committer | Justin Worthe <justin.worthe@entelect.co.za> | 2014-07-31 13:58:22 +0200 |
commit | 98ba22e7064db57316dfff1ae127feb3dceeb73e (patch) | |
tree | 1f7fe3065f804e491f558650285e8c6d05fc914b /source/logic/CollisionDetector.h |
Diffstat (limited to 'source/logic/CollisionDetector.h')
-rw-r--r-- | source/logic/CollisionDetector.h | 75 |
1 files changed, 75 insertions, 0 deletions
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 <list> +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<PlayerCar>& players, list<EnemyCar>& enemies, list<Checkpoint>& checkpoints, list<Rock>& rocks, list<Smokescreen>& 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 |