8 c.Type1 = (type1 < type2) ? type1 : type2;
9 c.Type2 = (type1 > type2) ? type1 : type2;
10 c.Callback = callback;
12 m_collisions.push_back(c);
29 m_nonCollisionIt = m_nonCollisions.begin();
30 for (; m_nonCollisionIt != m_nonCollisions.end(); m_nonCollisionIt++)
32 NonCollision nc = *m_nonCollisionIt;
33 if ((nc.Type1 == t1 && nc.Type2 == t2))
return;
36 m_collisionIt = m_collisions.begin();
37 for (; m_collisionIt != m_collisions.end(); m_collisionIt++)
39 Collision c = *m_collisionIt;
40 if ((c.Type1 == t1 && c.Type2 == t2))
45 float radiiSumSquared = radiiSum * radiiSum;
49 if (!swapped) c.Callback(pGameObject1, pGameObject2);
50 else c.Callback(pGameObject2, pGameObject1);
62 nc.Type1 = (type1 < type2) ? type1 : type2;
63 nc.Type2 = (type1 > type2) ? type1 : type2;
64 m_nonCollisions.push_back(nc);
void(* OnCollision)(GameObject *pGameObject1, GameObject *pGameObject2)
virtual void CheckCollision(GameObject *pGameObject1, GameObject *pGameObject2)
Check for collisions between game objects.
virtual void AddNonCollisionType(const CollisionType type1, const CollisionType type2)
Add a non-collision type to the manager.
virtual void AddCollisionType(const CollisionType type1, const CollisionType type2, OnCollision callback)
Add a collision type to the manager.
Represents a type of collision.
static const CollisionType None
Represents a game object in the game. This is the base class for all objects that can be updated,...
virtual CollisionType GetCollisionType() const =0
Get the collision type of the object.
virtual float GetCollisionRadius() const
Get the collision radius of the object.
virtual Vector2 & GetPosition()
Get the position of the object.
Defines a vector with 2 components (x and y).
float LengthSquared() const
Calculates the length of the vector squared.