diff options
Diffstat (limited to 'src/systems/animating.cpp')
| -rw-r--r-- | src/systems/animating.cpp | 30 | 
1 files changed, 30 insertions, 0 deletions
| diff --git a/src/systems/animating.cpp b/src/systems/animating.cpp index fcbfca5..91fe925 100644 --- a/src/systems/animating.cpp +++ b/src/systems/animating.cpp | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | #include "animating.h" | 1 | #include "animating.h" | 
| 2 | #include "game.h" | 2 | #include "game.h" | 
| 3 | #include "components/animatable.h" | 3 | #include "components/animatable.h" | 
| 4 | #include "components/transformable.h" | ||
| 4 | 5 | ||
| 5 | void AnimatingSystem::tick(double) | 6 | void AnimatingSystem::tick(double) | 
| 6 | { | 7 | { | 
| @@ -28,6 +29,35 @@ void AnimatingSystem::tick(double) | |||
| 28 | } | 29 | } | 
| 29 | } | 30 | } | 
| 30 | 31 | ||
| 32 | void AnimatingSystem::render(Texture& texture) | ||
| 33 | { | ||
| 34 | std::set<id_type> spriteEntities = | ||
| 35 | game_.getEntityManager().getEntitiesWithComponents< | ||
| 36 | AnimatableComponent, | ||
| 37 | TransformableComponent>(); | ||
| 38 | |||
| 39 | for (id_type entity : spriteEntities) | ||
| 40 | { | ||
| 41 | auto& sprite = game_.getEntityManager(). | ||
| 42 | getComponent<AnimatableComponent>(entity); | ||
| 43 | |||
| 44 | auto& transform = game_.getEntityManager(). | ||
| 45 | getComponent<TransformableComponent>(entity); | ||
| 46 | |||
| 47 | Rectangle dstrect { | ||
| 48 | static_cast<int>(transform.getX()), | ||
| 49 | static_cast<int>(transform.getY()), | ||
| 50 | transform.getW(), | ||
| 51 | transform.getH()}; | ||
| 52 | |||
| 53 | const AnimationSet& aset = sprite.getAnimationSet(); | ||
| 54 | texture.blit( | ||
| 55 | aset.getTexture(), | ||
| 56 | aset.getFrameRect(sprite.getFrame()), | ||
| 57 | dstrect); | ||
| 58 | } | ||
| 59 | } | ||
| 60 | |||
| 31 | void AnimatingSystem::startAnimation(id_type entity, std::string animation) | 61 | void AnimatingSystem::startAnimation(id_type entity, std::string animation) | 
| 32 | { | 62 | { | 
| 33 | auto& sprite = game_.getEntityManager(). | 63 | auto& sprite = game_.getEntityManager(). | 
