summary refs log tree commit diff stats
path: root/src/systems/animating.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-02-18 15:25:52 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-02-18 15:25:52 -0500
commite4e2f2d2a7b6a282b9618aa0004d9453936f43c6 (patch)
treede1653dc8b5992420147f28d9fb4de052ea1845f /src/systems/animating.cpp
parente16fb5be90c889c371cbb0ca2444735c2e12073c (diff)
downloadtherapy-e4e2f2d2a7b6a282b9618aa0004d9453936f43c6.tar.gz
therapy-e4e2f2d2a7b6a282b9618aa0004d9453936f43c6.tar.bz2
therapy-e4e2f2d2a7b6a282b9618aa0004d9453936f43c6.zip
Added player death and event scheduling
Also added ability to make sprites flicker, to freeze physics for an entity, and to freeze progression of a sprite's animation loop.
Diffstat (limited to 'src/systems/animating.cpp')
-rw-r--r--src/systems/animating.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/systems/animating.cpp b/src/systems/animating.cpp index 22224c9..634af67 100644 --- a/src/systems/animating.cpp +++ b/src/systems/animating.cpp
@@ -13,7 +13,10 @@ void AnimatingSystem::tick(double)
13 auto& sprite = game_.getEntityManager(). 13 auto& sprite = game_.getEntityManager().
14 getComponent<AnimatableComponent>(entity); 14 getComponent<AnimatableComponent>(entity);
15 15
16 sprite.setCountdown(sprite.getCountdown() + 1); 16 if (!sprite.isFrozen())
17 {
18 sprite.setCountdown(sprite.getCountdown() + 1);
19 }
17 20
18 const Animation& anim = sprite.getAnimation(); 21 const Animation& anim = sprite.getAnimation();
19 if (sprite.getCountdown() >= anim.getDelay()) 22 if (sprite.getCountdown() >= anim.getDelay())
@@ -26,6 +29,11 @@ void AnimatingSystem::tick(double)
26 sprite.setFrame(anim.getFirstFrame()); 29 sprite.setFrame(anim.getFirstFrame());
27 } 30 }
28 } 31 }
32
33 if (sprite.isFlickering())
34 {
35 sprite.setFlickerTimer((sprite.getFlickerTimer() + 1) % 6);
36 }
29 } 37 }
30} 38}
31 39
@@ -44,6 +52,12 @@ void AnimatingSystem::render(Texture& texture)
44 auto& transform = game_.getEntityManager(). 52 auto& transform = game_.getEntityManager().
45 getComponent<TransformableComponent>(entity); 53 getComponent<TransformableComponent>(entity);
46 54
55 double alpha = 1.0;
56 if (sprite.isFlickering() && (sprite.getFlickerTimer() < 3))
57 {
58 alpha = 0.0;
59 }
60
47 Rectangle dstrect { 61 Rectangle dstrect {
48 static_cast<int>(transform.getX()), 62 static_cast<int>(transform.getX()),
49 static_cast<int>(transform.getY()), 63 static_cast<int>(transform.getY()),
@@ -55,7 +69,8 @@ void AnimatingSystem::render(Texture& texture)
55 aset.getTexture(), 69 aset.getTexture(),
56 texture, 70 texture,
57 aset.getFrameRect(sprite.getFrame()), 71 aset.getFrameRect(sprite.getFrame()),
58 dstrect); 72 dstrect,
73 alpha);
59 } 74 }
60} 75}
61 76