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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.