diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2025-01-06 10:26:03 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2025-01-06 10:26:03 +0100 |
commit | d4f443070017c5c2e6a938bf4d0a86b70ae6beaa (patch) | |
tree | f3a6f399981d69e66916544e34066af6bce3fd93 /src/crepe/api/Animator.cpp | |
parent | ec69f40540317215d0f30e1f8e43d0e18450f8cc (diff) |
revert Animator
Diffstat (limited to 'src/crepe/api/Animator.cpp')
-rw-r--r-- | src/crepe/api/Animator.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/crepe/api/Animator.cpp b/src/crepe/api/Animator.cpp index f6f2654..c558d86 100644 --- a/src/crepe/api/Animator.cpp +++ b/src/crepe/api/Animator.cpp @@ -36,11 +36,24 @@ void Animator::pause() { this->active = false; } void Animator::stop() { this->active = false; - this->data.frame = this->data.cycle_start; + this->data.col = 0; + this->data.row = 0; } void Animator::set_fps(int fps) { this->data.fps = fps; } void Animator::set_cycle_range(int start, int end) { - this->data.cycle_start = start; - this->data.cycle_end = end; + this->data.cycle_start = start, this->data.cycle_end = end; +} + +void Animator::set_anim(int col) { + Animator::Data & ctx = this->data; + this->spritesheet.mask.x = ctx.row = 0; + ctx.col = col; + this->spritesheet.mask.y = ctx.col * this->spritesheet.mask.h; +} + +void Animator::next_anim() { + Animator::Data & ctx = this->data; + ctx.row = ++ctx.row % this->grid_size.x; + this->spritesheet.mask.x = ctx.row * this->spritesheet.mask.w; } |