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) ...

Get SFML Game Development By Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.