summary refs log tree commit diff stats
path: root/src
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
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')
-rw-r--r--src/character_system.cpp23
-rw-r--r--src/map.cpp2
-rw-r--r--src/sprite.h3
3 files changed, 25 insertions, 3 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
diff --git a/src/map.cpp b/src/map.cpp index 0425962..23445e4 100644 --- a/src/map.cpp +++ b/src/map.cpp
@@ -47,6 +47,8 @@ Map::Map(std::string_view name) : name_(name) {
47 } else if (property.getName() == "medium") { 47 } else if (property.getName() == "medium") {
48 if (property.getStringValue() == "ladder") { 48 if (property.getStringValue() == "ladder") {
49 tile.medium = CharacterMedium::Ladder; 49 tile.medium = CharacterMedium::Ladder;
50 } else if (property.getStringValue() == "water") {
51 tile.medium = CharacterMedium::Water;
50 } 52 }
51 } 53 }
52 } 54 }
diff --git a/src/sprite.h b/src/sprite.h index bb78442..32a082c 100644 --- a/src/sprite.h +++ b/src/sprite.h
@@ -36,7 +36,8 @@ enum class CharacterState {
36 36
37enum class CharacterMedium { 37enum class CharacterMedium {
38 Normal, 38 Normal,
39 Ladder 39 Ladder,
40 Water
40}; 41};
41 42
42struct Movement { 43struct Movement {