From b06b259c54e09f1a4026191d6eec9684599bd370 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Tue, 23 Feb 2021 22:22:49 -0500 Subject: Started working on ladders TODO: * all the animations are weird. we will need to have an adjustable framerate bc the climbing animation does not look right at the current rate. (also remove the manual animation stuff ig) * does the medium stuff seem good and right? i am kinda not satisfied with it. * running onto a ladder causes the characters to bunch up bc the movement speed is slowed down but the trails are not doubled * no ladder running sound * shadows should vanish while on a ladder * uhh if you end a cutscene while on a ladder it resets the animation to "still" which is wrong. will this ever happen? idk * adding a sprite to your party while you are on a ladder?? --- src/animation_system.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/animation_system.cpp') diff --git a/src/animation_system.cpp b/src/animation_system.cpp index d23eae2..a280aee 100644 --- a/src/animation_system.cpp +++ b/src/animation_system.cpp @@ -65,7 +65,7 @@ void AnimationSystem::initSprite(int spriteId, std::string_view filename) { std::string animLine; std::getline(datafile, animLine); // blank while (std::getline(datafile, animLine)) { - std::regex re(R"(([a-z!_]+)\[([a-z_]+)\]: ([0-9,]+))"); + std::regex re(R"(([a-z!._]+)\[([a-z_]+)\]: ([0-9,]+))"); std::smatch m; std::regex_match(animLine, m, re); @@ -78,6 +78,8 @@ void AnimationSystem::initSprite(int spriteId, std::string_view filename) { if (animName.back() == '!') { anim.looping = false; + } else if (animName.back() == '.') { + anim.manual = true; } int animId = sprite.animations.size(); @@ -96,7 +98,7 @@ void AnimationSystem::tick(double dt) { animTimer_.accumulate(dt); while (animTimer_.step()) { for (Sprite& sprite : game_.getSprites() | game_.spriteView()) { - if (sprite.isAnimated && !sprite.animFinished) { + if (sprite.isAnimated && !sprite.animFinished && !sprite.animPaused) { sprite.animationFrame++; if (sprite.animationFrame >= sprite.animations[sprite.animationId].frameIndices.size()) { @@ -112,6 +114,19 @@ void AnimationSystem::tick(double dt) { } } +void AnimationSystem::advanceAnimation(int spriteId) { + Sprite& sprite = game_.getSprite(spriteId); + Animation& animation = sprite.animations[sprite.animationId]; + + if (animation.manual) { + sprite.animationFrame++; + + if (sprite.animationFrame >= animation.frameIndices.size()) { + sprite.animationFrame = 0; + } + } +} + void AnimationSystem::setSpriteDirection(int spriteId, Direction dir) { Sprite& sprite = game_.getSprite(spriteId); if (sprite.dir != dir) { @@ -133,4 +148,5 @@ void AnimationSystem::updateAnimation(int spriteId) { sprite.animationId = sprite.nameDirToAnim[sprite.animationName][sprite.dir]; sprite.animationFrame = 0; sprite.animFinished = false; + sprite.animPaused = false; } -- cgit 1.4.1