summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/animation_system.cpp19
-rw-r--r--src/animation_system.h1
-rw-r--r--src/script_system.cpp3
-rw-r--r--src/sprite.h3
4 files changed, 24 insertions, 2 deletions
diff --git a/src/animation_system.cpp b/src/animation_system.cpp index ce5cc02..73d30d5 100644 --- a/src/animation_system.cpp +++ b/src/animation_system.cpp
@@ -166,6 +166,25 @@ void AnimationSystem::tick(double dt) {
166 } 166 }
167 } 167 }
168 } 168 }
169
170 fadingTimer_.accumulate(dt);
171 while (fadingTimer_.step()) {
172 for (Sprite& sprite : game_.getSprites() | game_.spriteView()) {
173 if (sprite.isAnimated) {
174 if (sprite.shouldBeFadedIn && sprite.opacity < 1.0) {
175 sprite.opacity += 0.05;
176 if (sprite.opacity > 1.0) {
177 sprite.opacity = 1.0;
178 }
179 } else if (!sprite.shouldBeFadedIn && sprite.opacity > 0.0) {
180 sprite.opacity -= 0.05;
181 if (sprite.opacity < 0.0) {
182 sprite.opacity = 0.0;
183 }
184 }
185 }
186 }
187 }
169} 188}
170 189
171void AnimationSystem::setSpriteDirection(int spriteId, Direction dir) { 190void AnimationSystem::setSpriteDirection(int spriteId, Direction dir) {
diff --git a/src/animation_system.h b/src/animation_system.h index 42aa516..7474c54 100644 --- a/src/animation_system.h +++ b/src/animation_system.h
@@ -31,6 +31,7 @@ private:
31 Game& game_; 31 Game& game_;
32 std::vector<Timer> animTimers_ = {{1000/5}, {1000/60}};//30fps * 1000 t/s;; 32 std::vector<Timer> animTimers_ = {{1000/5}, {1000/60}};//30fps * 1000 t/s;;
33 Timer bobbingTimer_ {1000/7}; 33 Timer bobbingTimer_ {1000/7};
34 Timer fadingTimer_ {1000/60};
34}; 35};
35 36
36#endif /* end of include guard: ANIMATION_SYSTEM_H_CCCC7CB8 */ 37#endif /* end of include guard: ANIMATION_SYSTEM_H_CCCC7CB8 */
diff --git a/src/script_system.cpp b/src/script_system.cpp index 56a6012..b4a7b9b 100644 --- a/src/script_system.cpp +++ b/src/script_system.cpp
@@ -56,7 +56,8 @@ ScriptSystem::ScriptSystem(Game& game) : game_(game) {
56 "behaviourType", &Sprite::behaviourType, 56 "behaviourType", &Sprite::behaviourType,
57 "followSpriteId", &Sprite::followSpriteId, 57 "followSpriteId", &Sprite::followSpriteId,
58 "interactionScript", &Sprite::interactionScript, 58 "interactionScript", &Sprite::interactionScript,
59 "opacity", &Sprite::opacity); 59 "opacity", &Sprite::opacity,
60 "shouldBeFadedIn", &Sprite::shouldBeFadedIn);
60 61
61 engine_.new_usertype<MessageSystem>( 62 engine_.new_usertype<MessageSystem>(
62 "message", 63 "message",
diff --git a/src/sprite.h b/src/sprite.h index 782ae14..e7cb55b 100644 --- a/src/sprite.h +++ b/src/sprite.h
@@ -100,13 +100,14 @@ public:
100 int bobAmount = 0; 100 int bobAmount = 0;
101 bool bobbingDown = false; 101 bool bobbingDown = false;
102 int animSlowdownProgress = 0; 102 int animSlowdownProgress = 0;
103 double opacity = 1.0;
104 103
105 // Animation (controls) 104 // Animation (controls)
106 bool normallyHasShadow = false; 105 bool normallyHasShadow = false;
107 bool animPaused = false; 106 bool animPaused = false;
108 bool bobbing = false; 107 bool bobbing = false;
109 int animSlowdown = 1; // Animation will only advance every X frames (so, 1 means it's disabled) 108 int animSlowdown = 1; // Animation will only advance every X frames (so, 1 means it's disabled)
109 double opacity = 1.0;
110 bool shouldBeFadedIn = true;
110 111
111 // Character 112 // Character
112 bool orientable = false; 113 bool orientable = false;