Simple C++ Game
|
A component of an entity in the game's component entity system. More...
#include <Entity.hpp>
Public Member Functions | |
Component (const std::string id) | |
Construct a new Component object. More... | |
virtual | ~Component () |
This is only declared to make the class polymorphic so that dymaic_cast between Component types works. | |
const std::string | getId () const |
Get the ID of the component. This will return the same value for all instances of a class of Component. | |
A component of an entity in the game's component entity system.
Components represent an aspect of an Entity. They store state information, such as position and sprite data, as well as mark the Entity as belong to a certain class of object, like being the player or an AI opponent.
Component types are identified with their ID, which is passed to the constructor. To avoid odd bugs and behavior, all instances of the same Component subclass should have the same ID, which is usually declared as a static member of the class or a preprocessor constant in the header file.
Entity::Component::Component | ( | const std::string | id | ) |