summaryrefslogtreecommitdiff
path: root/source/logic/CollisionDetector.h
blob: 294852d5e1a49794424ddb4b38b1498adb05507b (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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