Hi guys,
I am currently making a Mario clone in order to grasp the concept of building the tech to handle a platformer game (the engine and physics are where I get my kicks).
I have reached a point in the game design where I have now realised that the way in which I handle collisions is not ideal. I’ll explain my process briefly:
- I have a “Level1” gamestate class where I create a tile map and the entities (the player and enemies).
- The entities take a reference to the tile map in their constructor.
Each update:
- The entities calculate their next position based on velocity and handle their own tile map collisions.
- The collisions between entities (enemy-to-enemy and player-to-enemy) are handled in the PlayState class.
This works just fine, but the issue is that when I create a new level, I will be copy pasting the collision code for the entities, this smells to me like the entity collisions might be better off being handled within the entity class somehow as well but I can’t quite grasp how this would be done efficiently…
How do you guys handle the various collision types in your games (those of you who do your own )?