diff options
Diffstat (limited to 'src/crepe/system/AnimatorSystem.cpp')
-rw-r--r-- | src/crepe/system/AnimatorSystem.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/crepe/system/AnimatorSystem.cpp b/src/crepe/system/AnimatorSystem.cpp index 9aede7f..549c35d 100644 --- a/src/crepe/system/AnimatorSystem.cpp +++ b/src/crepe/system/AnimatorSystem.cpp @@ -1,8 +1,8 @@ #include "../api/Animator.h" -#include "../facade/SDLContext.h" #include "../manager/ComponentManager.h" +#include "api/LoopTimer.h" #include "AnimatorSystem.h" @@ -10,27 +10,27 @@ using namespace crepe; void AnimatorSystem::update() { ComponentManager & mgr = this->mediator.component_manager; - + LoopTimer & timer = this->mediator.timer; RefVector<Animator> animations = mgr.get_components_by_type<Animator>(); - double elapsed_time = this->timer.get_current_time(); + double elapsed_time = timer.get_current_time(); for (Animator & a : animations) { if (!a.active) continue; Animator::Data & ctx = a.data; - double frame_duration = 1.0f / ctx.fps; + float frame_duration = 1.0f / ctx.fps; - int last_frame = ctx.curr_row; + int last_frame = ctx.row; - int cycle_end = (ctx.cycle_end == -1) ? a.row : ctx.cycle_end; + int cycle_end = (ctx.cycle_end == -1) ? a.max_rows : ctx.cycle_end; int total_frames = cycle_end - ctx.cycle_start; int curr_frame = static_cast<int>(elapsed_time / frame_duration) % total_frames; - ctx.curr_row = ctx.cycle_start + curr_frame; - a.spritesheet.mask.x = ctx.curr_row * a.spritesheet.mask.w; - a.spritesheet.mask.y = (ctx.curr_col * a.spritesheet.mask.h); + ctx.row = ctx.cycle_start + curr_frame; + a.spritesheet.mask.x = ctx.row * a.spritesheet.mask.w; + a.spritesheet.mask.y = (ctx.col * a.spritesheet.mask.h); if (!ctx.looping && curr_frame == ctx.cycle_start && last_frame == total_frames - 1) { a.active = false; |