Implementing the rendering system
In order for entities to be drawn on screen, they must have a component that represents them visually. After some careful planning, one can deduce that an entity will probably not have just one possible choice for a graphical representation. For example, instead of a sprite sheet, an entity can be a simple shape with a single color fill. In order to make that happen, we need a common interface for drawable components. Let's see what we can come up with:
class C_Drawable : public C_Base{ public: C_Drawable(const Component& l_type) : C_Base(l_type){} virtual ~C_Drawable(){} virtual void UpdatePosition(const sf::Vector2f& l_vec) = 0; virtual const sf::Vector2u& GetSize() = 0; virtual void Draw(sf::RenderWindow* l_wind) = 0; private: };
The first thing to note here is that the constructor of this class also takes in a component type, and simply passes it to the base class. Since C_Drawable
only has purely virtual methods, it can never be...