Hello,
for a new game i am thinking about to create i need a Gameworld, which contains all the entities and manages the collision detection between them.
The game is a 2D Tile-based game and contains 3 entity types:
- Type A: Static/Non-moving entity (“Blocks”)
- Type B: Controlable entities (Player and NPCs)
- Type C: Other moving entities like projectiles, which are not controlled by AI or Input
The entities cannot collide with other entities of the same type. That means, Type B entities cannot collide with other Type B entities, Type C entities cannot collide with other Type C entities.
Therefore i thoguht the Gameworld should have:
A 2D Array of Type A entities, as the game is Tile-based and the Type A entities won’t move,
A List of Type B entities and
A List of Type C entities.
Then i could cycle through the Type B list and for every Type B check:
- If the 2D Array of Type A entities contains a value at my new position
- Cycle through the Type C list and for every Type C entity check if it collides with my Type B
Also for every entity in the Type C list i would need to check, if it collides with one of the Type A entities.
The advantage i see is, that i don’t need to check every entity-combination, but only the combinations, that can collide with each other. Also the check between moving entities and “Blocks” should be quit efficient this way.
What do you think about this method? Is it good practice to sepperate the different entity-types in different lists?