diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2015-03-07 11:29:57 -0500 |
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2015-03-07 11:29:57 -0500 |
| commit | b53826079429939cdfbda073608cb85be8ba0738 (patch) | |
| tree | 3c40de4658f0cea01cd3938f07fe82788ef3dd01 /src/entity.cpp | |
| parent | 0751446e1d069263d25abcff49a32a380231709a (diff) | |
| download | therapy-b53826079429939cdfbda073608cb85be8ba0738.tar.gz therapy-b53826079429939cdfbda073608cb85be8ba0738.tar.bz2 therapy-b53826079429939cdfbda073608cb85be8ba0738.zip | |
Created entity-component system
Also tweaked the bloom flicker, tweaked the scanline texture, created a second test map, and created some currently unused sound effects.
Diffstat (limited to 'src/entity.cpp')
| -rw-r--r-- | src/entity.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
| diff --git a/src/entity.cpp b/src/entity.cpp new file mode 100644 index 0000000..405de24 --- /dev/null +++ b/src/entity.cpp | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | #include "entity.h" | ||
| 2 | |||
| 3 | void Entity::addComponent(std::shared_ptr<Component> c) | ||
| 4 | { | ||
| 5 | components.push_back(c); | ||
| 6 | } | ||
| 7 | |||
| 8 | void Entity::send(message_t msg) | ||
| 9 | { | ||
| 10 | for (auto it = components.begin(); it != components.end(); it++) | ||
| 11 | { | ||
| 12 | (*it)->receive(msg); | ||
| 13 | } | ||
| 14 | } | ||
| 15 | |||
| 16 | void Entity::tick() | ||
| 17 | { | ||
| 18 | for (auto it = components.begin(); it != components.end(); it++) | ||
| 19 | { | ||
| 20 | (*it)->tick(); | ||
| 21 | } | ||
| 22 | } | ||
| 23 | |||
| 24 | void Entity::input(int key, int action) | ||
| 25 | { | ||
| 26 | for (auto it = components.begin(); it != components.end(); it++) | ||
| 27 | { | ||
| 28 | (*it)->input(key, action); | ||
| 29 | } | ||
| 30 | } | ||
| 31 | |||
| 32 | void Entity::render(Texture* buffer) | ||
| 33 | { | ||
| 34 | for (auto it = components.begin(); it != components.end(); it++) | ||
| 35 | { | ||
| 36 | (*it)->render(buffer); | ||
| 37 | } | ||
| 38 | } | ||
