diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-23 22:22:49 -0500 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2021-02-24 16:00:53 -0500 |
commit | b06b259c54e09f1a4026191d6eec9684599bd370 (patch) | |
tree | f31b241c3da5559d388d97bf9e65c2104f4652e8 /src/animation_system.cpp | |
parent | ae654356f843bb42a3c72d57b528d87aa63cf66d (diff) | |
download | tanetane-b06b259c54e09f1a4026191d6eec9684599bd370.tar.gz tanetane-b06b259c54e09f1a4026191d6eec9684599bd370.tar.bz2 tanetane-b06b259c54e09f1a4026191d6eec9684599bd370.zip |
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??
Diffstat (limited to 'src/animation_system.cpp')
-rw-r--r-- | src/animation_system.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
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) { | |||
65 | std::string animLine; | 65 | std::string animLine; |
66 | std::getline(datafile, animLine); // blank | 66 | std::getline(datafile, animLine); // blank |
67 | while (std::getline(datafile, animLine)) { | 67 | while (std::getline(datafile, animLine)) { |
68 | std::regex re(R"(([a-z!_]+)\[([a-z_]+)\]: ([0-9,]+))"); | 68 | std::regex re(R"(([a-z!._]+)\[([a-z_]+)\]: ([0-9,]+))"); |
69 | std::smatch m; | 69 | std::smatch m; |
70 | std::regex_match(animLine, m, re); | 70 | std::regex_match(animLine, m, re); |
71 | 71 | ||
@@ -78,6 +78,8 @@ void AnimationSystem::initSprite(int spriteId, std::string_view filename) { | |||
78 | 78 | ||
79 | if (animName.back() == '!') { | 79 | if (animName.back() == '!') { |
80 | anim.looping = false; | 80 | anim.looping = false; |
81 | } else if (animName.back() == '.') { | ||
82 | anim.manual = true; | ||
81 | } | 83 | } |
82 | 84 | ||
83 | int animId = sprite.animations.size(); | 85 | int animId = sprite.animations.size(); |
@@ -96,7 +98,7 @@ void AnimationSystem::tick(double dt) { | |||
96 | animTimer_.accumulate(dt); | 98 | animTimer_.accumulate(dt); |
97 | while (animTimer_.step()) { | 99 | while (animTimer_.step()) { |
98 | for (Sprite& sprite : game_.getSprites() | game_.spriteView()) { | 100 | for (Sprite& sprite : game_.getSprites() | game_.spriteView()) { |
99 | if (sprite.isAnimated && !sprite.animFinished) { | 101 | if (sprite.isAnimated && !sprite.animFinished && !sprite.animPaused) { |
100 | sprite.animationFrame++; | 102 | sprite.animationFrame++; |
101 | 103 | ||
102 | if (sprite.animationFrame >= sprite.animations[sprite.animationId].frameIndices.size()) { | 104 | if (sprite.animationFrame >= sprite.animations[sprite.animationId].frameIndices.size()) { |
@@ -112,6 +114,19 @@ void AnimationSystem::tick(double dt) { | |||
112 | } | 114 | } |
113 | } | 115 | } |
114 | 116 | ||
117 | void AnimationSystem::advanceAnimation(int spriteId) { | ||
118 | Sprite& sprite = game_.getSprite(spriteId); | ||
119 | Animation& animation = sprite.animations[sprite.animationId]; | ||
120 | |||
121 | if (animation.manual) { | ||
122 | sprite.animationFrame++; | ||
123 | |||
124 | if (sprite.animationFrame >= animation.frameIndices.size()) { | ||
125 | sprite.animationFrame = 0; | ||
126 | } | ||
127 | } | ||
128 | } | ||
129 | |||
115 | void AnimationSystem::setSpriteDirection(int spriteId, Direction dir) { | 130 | void AnimationSystem::setSpriteDirection(int spriteId, Direction dir) { |
116 | Sprite& sprite = game_.getSprite(spriteId); | 131 | Sprite& sprite = game_.getSprite(spriteId); |
117 | if (sprite.dir != dir) { | 132 | if (sprite.dir != dir) { |
@@ -133,4 +148,5 @@ void AnimationSystem::updateAnimation(int spriteId) { | |||
133 | sprite.animationId = sprite.nameDirToAnim[sprite.animationName][sprite.dir]; | 148 | sprite.animationId = sprite.nameDirToAnim[sprite.animationName][sprite.dir]; |
134 | sprite.animationFrame = 0; | 149 | sprite.animationFrame = 0; |
135 | sprite.animFinished = false; | 150 | sprite.animFinished = false; |
151 | sprite.animPaused = false; | ||
136 | } | 152 | } |