SDL SPOOKY PLATFORMER ENGINE  0.2.0
An implementation of a platformer using sdl, implemented using an entity component system and efficient collision management.
GameObject.hpp
Go to the documentation of this file.
1 #ifndef GAMEOBJECT_HPP
2 #define GAMEOBJECT_HPP
3 
4 #include <vector>
5 #include <algorithm>
6 #include <string>
7 
8 #include "SDL2/SDL.h"
9 
10 class Component;
11 
13 {
14 public:
15  GameObject(std::string tag);
17  ~GameObject();
18 
20  std::string GetTag();
21 
23  virtual void Update(float fixedTime);
24 
26  virtual void Render(SDL_Renderer* ren);
27 
29  template <typename T, typename... TArgs>
30  void AddComponent(TArgs&&... mArgs);
31 
33  void RemoveComponent(Component* c);
34 
36  template<typename C>
37  C* GetComponent() const;
38 
39 protected:
40  std::vector<Component*> m_components;
41  std::string m_tag;
42 };
43 
44 #include "GameObject.tpp"
45 
46 #endif
std::string m_tag
Definition: GameObject.hpp:41
std::vector< Component * > m_components
Definition: GameObject.hpp:40
C * GetComponent() const
Get a component.
void AddComponent(TArgs &&...mArgs)
Add a component.
virtual void Render(SDL_Renderer *ren)
Render this object.
Definition: GameObject.cpp:34
virtual void Update(float fixedTime)
update this GameObject on a frame basis
Definition: GameObject.cpp:26
std::string GetTag()
return this game objects tag
Definition: GameObject.cpp:42
~GameObject()
default deconstructor for deallocating components
Definition: GameObject.cpp:8
GameObject(std::string tag)
Definition: GameObject.cpp:4
void RemoveComponent(Component *c)
Remove a component.
Definition: GameObject.cpp:16
Definition: GameObject.hpp:12
Definition: Component.hpp:13