Shkyera Engine
Easy to use, game engine for Python
ShapeComponent.hpp
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include "game/Component.hpp"
10 #include "renderer/Renderer.hpp"
11 #include <vector>
12 
13 namespace shkyera {
14 
24 class ShapeComponent : public Component {
25  public:
32 
38  void setRenderer(std::shared_ptr<Renderer> renderer);
39 
46  virtual void drawShape() = 0;
47 
53  static void addShape(std::shared_ptr<ShapeComponent> shape);
54 
60  static void removeShape(std::shared_ptr<ShapeComponent> shape);
61 
67  static std::vector<std::shared_ptr<ShapeComponent>> getShapes();
68 
69  protected:
70  std::shared_ptr<Renderer> _renderer; //< The renderer used for rendering the shape.
71 
72  private:
73  static std::vector<std::shared_ptr<ShapeComponent>> _shapes; //< List of managed shape components.
74 };
75 
76 } // namespace shkyera
Contains the declaration of the Component class, a base class for game components.
A base class representing a component attached to a game object.
Definition: Component.hpp:20
Component(std::shared_ptr< GameObject > object)
Constructor to initialize a component with a shared pointer to a game object.
Definition: Component.cpp:5
A base component for handling shapes within a game or application.
Definition: ShapeComponent.hpp:24
static void removeShape(std::shared_ptr< ShapeComponent > shape)
Remove a shape component from the list of managed shapes.
Definition: ShapeComponent.cpp:7
std::shared_ptr< Renderer > _renderer
Definition: ShapeComponent.hpp:70
static std::vector< std::shared_ptr< ShapeComponent > > _shapes
Definition: ShapeComponent.hpp:73
static void addShape(std::shared_ptr< ShapeComponent > shape)
Add a shape component to the list of managed shapes.
Definition: ShapeComponent.cpp:6
static std::vector< std::shared_ptr< ShapeComponent > > getShapes()
Get the list of managed shape components.
Definition: ShapeComponent.cpp:8
virtual void drawShape()=0
Draw the shape.
void setRenderer(std::shared_ptr< Renderer > renderer)
Set the renderer for this shape component.
Definition: ShapeComponent.cpp:5
Definition: Entity.cpp:3