Hey ravinDavin,
You may want to look at Box2D, it handles collisions very nicely.
If you don't want to do that, here is a simple way:
When you create an entity, also create a PhysicsObject and give it to the PhysicsSystem.
- A PhysicsObject contains a Shape reference.
- A Shape is something that defines the shape of the collision (Shape, Circle, Polygon) and holds the data for it.
- A PhysicsObject contains a Position reference.
- A PhysicsObject contains the entity that it is used for.
- A PhysicsObject contains a vector of PhysicsObjects, which is cleared when GetCollisions is called, which returns this vector.
- May also want to make physicsobjects that are just triggers (So a bool isTrigger so it won't act solid but still report it's collision)
- A PhysicsSystem contains a vector of PhysicsObjects
- A PhysicsSystem has an update function, which checks all PhysicsObjects for collisions and places PhysicsObjects into other PhysicsObjects if a collision occured.
- You could even do collision response with this
An entity could then check what entity is attached to the physicsobject by using a name or reinterpret_cast or something and do something based on that. You could also make it so physicsobjects can contain multiple shapes so you can define stuff using simple shapes.
EDIT: You should have a list of entities somewhere, because you will most probably need to call an update function on them to do any logic that they contain (Like scale up and down or something). But your game logic (entity update function) shouldn't really be apart of your physics, your physics or collisions should 'just happen'. (IMO)