aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system/AnimatorSystem.cpp
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-02 20:02:14 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-02 20:02:14 +0100
commita84ca09e97d466643f022acfffcf4c6a77f42052 (patch)
treef375067b4250f468eb3b57d968efa3417f0f521d /src/crepe/system/AnimatorSystem.cpp
parent135af8b0e0eaf8a5a5b7e1a42bfb20bb14ec97e5 (diff)
making struct constructors
Diffstat (limited to 'src/crepe/system/AnimatorSystem.cpp')
-rw-r--r--src/crepe/system/AnimatorSystem.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/crepe/system/AnimatorSystem.cpp b/src/crepe/system/AnimatorSystem.cpp
index 1650b3d..b1f23d1 100644
--- a/src/crepe/system/AnimatorSystem.cpp
+++ b/src/crepe/system/AnimatorSystem.cpp
@@ -17,20 +17,21 @@ void AnimatorSystem::update() {
for (Animator & a : animations) {
if (!a.active) continue;
+
+ Animator::Data & ctx = a.data;
+ double frame_duration = 1.0f / ctx.fps;
- double frame_duration = 1.0f / a.fps;
-
- int cycle_end = (a.cycle_end == -1) ? a.row : cycle_end;
- int total_frames = cycle_end - a.cycle_start;
+ int cycle_end = (ctx.cycle_end == -1) ? ctx.row : cycle_end;
+ int total_frames = cycle_end - ctx.cycle_start;
int curr_frame = static_cast<int>(elapsed_time / frame_duration) % total_frames;
- a.curr_row = a.cycle_start + curr_frame;
- a.spritesheet.mask.x = a.curr_row * a.spritesheet.mask.w;
- a.spritesheet.mask.y = (a.curr_col * a.spritesheet.mask.h);
+ ctx.curr_row = ctx.cycle_start + curr_frame;
+ ctx.spritesheet.mask.x = ctx.curr_row * ctx.spritesheet.mask.w;
+ ctx.spritesheet.mask.y = (ctx.curr_col * ctx.spritesheet.mask.h);
std::cout << curr_frame << " " << total_frames << std::endl;
- if (!a.looping && curr_frame == 0) {
+ if (!ctx.looping && curr_frame == 0) {
a.active = false;
}
}