I am developing a top down 'thing' in SFML and C++ and was wondering about how best to handle so called Entities in my game.
An entity, for example is defined by me as an object in-game, such as a door to a house, that can be interacted with, can be animated, can act on user input, can be affected by physics etc.
I was thinking of handling this system by a series of classes and subclasses.
For example, the base class of Entity would contain the methods Render
, Update
, HandleInput
and such as these are the most basic methods that all entities will contain. Variables of the main class could include isVisible
, isPhysical
, drawDepth
and so on.
A new class for MapObject
would use inheritance to take the methods from Entity and may also add other methods and variables such as tileTexture
, tileHeight
and tileWidth
.
Abstracting(?) from that again could be the DoorTile
class which would handle the item specific level of input handling and interaction.
Is this a valid way to handle objects in-game? Are there and glaring errors?(Bear in mind I've been awake for many many hours :p)
Sorry if this is somewhat long-winded, I wanted to be specific as to how my proposed system would work.