aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system/AnimatorSystem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe/system/AnimatorSystem.cpp')
-rw-r--r--src/crepe/system/AnimatorSystem.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/crepe/system/AnimatorSystem.cpp b/src/crepe/system/AnimatorSystem.cpp
index 9d18873..4c40940 100644
--- a/src/crepe/system/AnimatorSystem.cpp
+++ b/src/crepe/system/AnimatorSystem.cpp
@@ -1,6 +1,4 @@
#include <cstdint>
-#include <functional>
-#include <vector>
#include "api/Animator.h"
#include "facade/SDLContext.h"
@@ -13,15 +11,14 @@ using namespace crepe;
void AnimatorSystem::update() {
ComponentManager & mgr = this->component_manager;
- std::vector<std::reference_wrapper<Animator>> animations
- = mgr.get_components_by_type<Animator>();
+ RefVector<Animator> animations = mgr.get_components_by_type<Animator>();
uint64_t tick = SDLContext::get_instance().get_ticks();
for (Animator & a : animations) {
- if (a.active) {
- a.curr_row = (tick / 100) % a.row;
- a.animator_rect.x = (a.curr_row * a.animator_rect.w) + a.curr_col;
- a.spritesheet.sprite_rect = a.animator_rect;
- }
+ if (!a.active) continue;
+ // (10 frames per second)
+ a.curr_row = (tick / 100) % a.row;
+ a.spritesheet.mask.x = (a.curr_row * a.spritesheet.mask.w) + a.curr_col;
+ a.spritesheet.mask = a.spritesheet.mask;
}
}