summary refs log tree commit diff stats
path: root/src/character_system.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2021-02-24 17:50:06 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2021-02-24 17:50:06 -0500
commit7747a943b1831eca1be213610a729f8071ebd5d7 (patch)
treeb6265f43be9b9c21bba92d855d870630d7df5c40 /src/character_system.cpp
parenta3585e9928f290465e514f0eef3baa147679f075 (diff)
downloadtanetane-7747a943b1831eca1be213610a729f8071ebd5d7.tar.gz
tanetane-7747a943b1831eca1be213610a729f8071ebd5d7.tar.bz2
tanetane-7747a943b1831eca1be213610a729f8071ebd5d7.zip
Added animation for being in a hot spring
Diffstat (limited to 'src/character_system.cpp')
-rw-r--r--src/character_system.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/character_system.cpp b/src/character_system.cpp index bc02e6c..bcd3beb 100644 --- a/src/character_system.cpp +++ b/src/character_system.cpp
@@ -75,7 +75,8 @@ void CharacterSystem::moveInDirection(int spriteId, Direction dir) {
75 sprite.movementDir = dir; 75 sprite.movementDir = dir;
76 76
77 switch (sprite.characterMedium) { 77 switch (sprite.characterMedium) {
78 case CharacterMedium::Normal: { 78 case CharacterMedium::Normal:
79 case CharacterMedium::Water: {
79 game_.getSystem<AnimationSystem>().setSpriteDirection(spriteId, dir); 80 game_.getSystem<AnimationSystem>().setSpriteDirection(spriteId, dir);
80 break; 81 break;
81 } 82 }
@@ -171,6 +172,12 @@ void CharacterSystem::tick(double dt) {
171 sprite.characterMedium = newMedium; 172 sprite.characterMedium = newMedium;
172 setAnimationFor(spriteId, sprite.characterState); 173 setAnimationFor(spriteId, sprite.characterState);
173 adjustPartyTrails(spriteId); 174 adjustPartyTrails(spriteId);
175
176 // Stop running if you go into water.
177 if (newMedium == CharacterMedium::Water &&
178 sprite.characterState == CharacterState::Running) {
179 stopRunning(spriteId);
180 }
174 } 181 }
175 182
176 if (sprite.characterState == CharacterState::Running) { 183 if (sprite.characterState == CharacterState::Running) {
@@ -214,7 +221,8 @@ void CharacterSystem::beginCrouch(int spriteId) {
214 if (sprite.characterState == CharacterState::Running) { 221 if (sprite.characterState == CharacterState::Running) {
215 stopRunning(spriteId); 222 stopRunning(spriteId);
216 } else { 223 } else {
217 if (sprite.characterMedium == CharacterMedium::Ladder) { 224 if (sprite.characterMedium == CharacterMedium::Ladder ||
225 sprite.characterMedium == CharacterMedium::Water) {
218 return; 226 return;
219 } 227 }
220 228
@@ -323,6 +331,17 @@ void CharacterSystem::setAnimationFor(int spriteId, CharacterState state) {
323 331
324 break; 332 break;
325 } 333 }
334 case CharacterMedium::Water: {
335 std::string animName = "swim_still";
336 if (state == CharacterState::Walking) {
337 animName = "swim_walk";
338 }
339
340 game_.getSystem<AnimationSystem>().setSpriteAnimation(spriteId, animName);
341 sprite.hasShadow = false;
342
343 break;
344 }
326 } 345 }
327} 346}
328 347