An Entity System
As part of an exercise using SFML I received a rather simple task of collision detection with rectangles for the week, as well as the use of some vectors (In this case point-based, not array-like vectors). What I did initially was create a player instance and a few ‘buildings’ for collision testing.
What I also did was incorporate a little entity system that I’m quite happy with. The only thing required to add an entity now is _entManager.AddEntity(entity_type,xPos,yPos,
An abstract base class, in this case a WorldObject serves as the base of each entity type. It assigns a collision rectangle and a unique ID. This way, I can add as many instances of an entity without having to worry about naming problems, and the collision system is automatically set up as well.
Right now I’m using a static cast to convert the ‘WorldObject’ that the player class inherits from back to the player, which might not be the greatest design method but it works.