Arcade Shooter
CollisionManager.h
1 
2 /* . ,'`. .
3  . .." _.-;' ⁄‚ `. . `
4  _.-"`.##%"_.--" ,' ⁄` `. "#" ___,,od000
5  ,'"-_ _.-.--"\ ,' `-_ '%#%',,/00000000000
6  ,' |_.' )`/- __..--""`-_`-._ J L/00000000000000
7  . + ,' _.-" / / _-"" `-._`-_/___\///0000 000M
8  .'_.-"" ' :_/_.-' _,`-/__V__\0000 00MMM
9  . _-"" . ' _,/000\ | /000 0MMMMM
10 _-" . ' . . ,/ 000\ | /000000000MMMMM
11  ` Shooter Library ' ,/ 000\|/000000000MMMMMM
12 . © 2017 - Shuriken Studios LLC ,/0 00000|0000000000MMMMMM */
13 
14 #pragma once
15 
16 namespace ShooterLibrary
17 {
20  typedef void(*OnCollision)(GameObject *pGameObject1, GameObject *pGameObject2);
21 
22 
31  {
32 
33  public:
34 
35  virtual ~CollisionManager() { }
36 
37 
42  virtual void AddCollisionType(const CollisionType type1, const CollisionType type2, OnCollision callback);
43 
50  virtual void AddNonCollisionType(const CollisionType type1, const CollisionType type2);
51 
58  virtual void CheckCollision(GameObject *pGameObject1, GameObject *pGameObject2);
59 
60 
61  private:
62 
63  struct NonCollision
64  {
65  CollisionType Type1;
66  CollisionType Type2;
67  };
68 
69  struct Collision
70  {
71  CollisionType Type1;
72  CollisionType Type2;
73  OnCollision Callback;
74  };
75 
76  std::vector<NonCollision> m_nonCollisions;
77  std::vector<NonCollision>::iterator m_nonCollisionIt;
78 
79  std::vector<Collision> m_collisions;
80  std::vector<Collision>::iterator m_collisionIt;
81 
82  };
83 }
Handles collisions between game objects.
Definition: CollisionManager.h:30
void(* OnCollision)(GameObject *pGameObject1, GameObject *pGameObject2)
Callback function for handling collisions.
Definition: CollisionManager.h:20
Base class for all objects that will be updated and rendered on a GameplayScreen. ...
Definition: GameObject.h:29
Shooter Library is a library of classes, interfaces, and value types that provides a foundation for d...
Definition: Background.h:16
virtual void AddCollisionType(const CollisionType type1, const CollisionType type2, OnCollision callback)
Adds a type of collision occurance to the manager.
Definition: CollisionManager.cpp:18
virtual void CheckCollision(GameObject *pGameObject1, GameObject *pGameObject2)
Determines if two objects are colliding. If they are the specified callback function is run...
Definition: CollisionManager.cpp:28
virtual void AddNonCollisionType(const CollisionType type1, const CollisionType type2)
Adds a type of collision occurance to make the manager ignore.
Definition: CollisionManager.cpp:72
Defines the types of game objects that can collide with each other.
Definition: CollisionType.h:20