Coding the collider components
The Space Invaders ++ game will only have one simple type of collider. It will be a rectangular box around the object, just like those we had in the Zombie Apocalypse and Pong games. However, it is easily conceivable that you might need other types of collider; perhaps a circle-shaped collider or a non-encompassing collider such as those we used for the head, feet, and sides of Thomas and Bob back in the Thomas Was Late game.
For this reason, there will be a base ColliderComponent
class (that inherits from Component
) which will handle the basic functionality of all the colliders, as well as RectColliderComponent
, which will add the specific functionality of an all-encompassing rectangle-shaped collider. New collider types can then be added as required for the game being developed.
What follows is the base class to the specific collider, ColliderComponent
.
Coding the ColliderComponent class
Create a new header file in the Header Files/GameObjects...