aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api/Animator.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/api/Animator.cpp
parent135af8b0e0eaf8a5a5b7e1a42bfb20bb14ec97e5 (diff)
making struct constructors
Diffstat (limited to 'src/crepe/api/Animator.cpp')
-rw-r--r--src/crepe/api/Animator.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/crepe/api/Animator.cpp b/src/crepe/api/Animator.cpp
index 0b7e86d..ce824e6 100644
--- a/src/crepe/api/Animator.cpp
+++ b/src/crepe/api/Animator.cpp
@@ -7,37 +7,37 @@
using namespace crepe;
-Animator::Animator(game_object_id_t id, Sprite & ss, int row, int col, int col_animator)
+Animator::Animator(game_object_id_t id, const Animator::Data & ctx)
: Component(id),
- spritesheet(ss),
- row(row),
- col(col) {
+ data(ctx)
+{
dbg_trace();
- this->spritesheet.mask.h /= col;
- this->spritesheet.mask.w /= row;
- this->spritesheet.mask.x = 0;
- this->spritesheet.mask.y = col_animator * this->spritesheet.mask.h;
+ this->data.spritesheet.mask.h /= this->data.col;
+ this->data.spritesheet.mask.w /= this->data.row;
+ this->data.spritesheet.mask.x = 0;
+ this->data.spritesheet.mask.y = this->data.col * this->data.spritesheet.mask.h;
// need to do this for to get the aspect ratio for a single clipping in the spritesheet
- this->spritesheet.aspect_ratio
- = static_cast<double>(this->spritesheet.mask.w) / this->spritesheet.mask.h;
+ Sprite & ss = this->data.spritesheet;
+ ss.data.aspect_ratio
+ = static_cast<double>(this->data.spritesheet.mask.w) / this->data.spritesheet.mask.h;
}
Animator::~Animator() { dbg_trace(); }
-void Animator::loop() { this->looping = true; }
+void Animator::loop() { this->data.looping = true; }
void Animator::play() { this->active = true; }
void Animator::pause() { this->active = false; }
void Animator::stop() {
this->active = false;
- this->curr_col = 0;
- this->curr_row = 0;
+ this->data.curr_col = 0;
+ this->data.curr_row = 0;
}
-void Animator::set_fps(int fps) { this->fps = fps; }
+void Animator::set_fps(int fps) { this->data.fps = fps; }
void Animator::set_cycle_range(int start, int end) {
- this->cycle_start = start, this->cycle_end = end;
+ this->data.cycle_start = start, this->data.cycle_end = end;
}
void Animator::set_anim(int col) {
- this->curr_row = 0;
- this->curr_col = col;
+ this->data.curr_row = 0;
+ this->data.curr_col = col;
}