How to design 2D collision callback methods?
- by Ahmed Fakhry
In a 2D game where you have a lot of possible combination of collision between objects, such as:
object A vs object B = object B vs A;
object A vs object C = object C vs A;
object A vs object D = object D vs A;
and so on ...
Do we need to create callback methods for all single type of collision? and do we need to create the same method twice? Like, say a bullet hits a wall, now I need a method to penetrate the wall for the wall, and a method to destroy the bullet for the bullet!!
At the same time, a bullet can hit many objects in the game, and hence, more different callback methods!!!
Is there a design pattern for that?