I'm in the process of building a new 2D game out of some code I wrote a while ago.
The object hierarchy for entities is like this:
MainMenu): Contains multiple entities and delegates
Entity: Base class for all things in a scene (e.g.
Sprite: Base class for all entities that just draw a texture, i.e. don't have their own drawing logic
Does it make sense to split up entities and sprites up like that? I think in a 2D game, the terms entity and sprite are somewhat synonymous, right?
But I do believe that I need some base class for entities that just draw a texture, as opposed to drawing themselves, to avoid duplication. Most entities are like that.
One weird case is my
Text class: It derives from
Sprite, which accepts either the path of an image or an already loaded texture in its constructor.
Text loads a texture in its constructor and passes that to
Can you outline a design that makes more sense? Or point me to a good object-oriented reference code base for a 2D game? I could only find 3D engine code bases of decent code quality, e.g. Doom 3 and HPL1Engine.