diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-12-10 16:21:05 +0100 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-12-10 16:21:05 +0100 |
commit | 7b8de90699aea153e73b5f2cee05c69b966b81be (patch) | |
tree | 123f8b71b59a933b2bfcffb9e43e5bea66086d8f /src/crepe/api/Animator.cpp | |
parent | 33cd5566909ac089cdf56db38a3d1daf0cb7dd10 (diff) |
implemented feedback wouter, improved animator. however if spritesheet aspect_ratio is not the same as the single frame then the scaling is wrong
Diffstat (limited to 'src/crepe/api/Animator.cpp')
-rw-r--r-- | src/crepe/api/Animator.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/crepe/api/Animator.cpp b/src/crepe/api/Animator.cpp index ad1778d..4c72cc0 100644 --- a/src/crepe/api/Animator.cpp +++ b/src/crepe/api/Animator.cpp @@ -7,20 +7,18 @@ using namespace crepe; -Animator::Animator(game_object_id_t id, Sprite & spritesheet, unsigned int pixel_frame_x, - unsigned int pixel_frame_y, unsigned int max_row, unsigned int max_col, - const Animator::Data & data) +Animator::Animator(game_object_id_t id, Sprite & spritesheet, const ivec2 & single_frame_size, + const uvec2 & max_cell_size, const Animator::Data & data) : Component(id), spritesheet(spritesheet), - max_rows(max_row), - max_columns(max_col), + max_cell_size(max_cell_size), data(data) { dbg_trace(); - this->spritesheet.mask.h = this->max_columns * pixel_frame_y; - this->spritesheet.mask.w /= this->max_rows * pixel_frame_x; - this->spritesheet.mask.x = this->data.row * this->spritesheet.mask.w; - this->spritesheet.mask.y = this->data.col * this->spritesheet.mask.h; + this->spritesheet.mask.w = single_frame_size.x; + this->spritesheet.mask.h = single_frame_size.y; + this->spritesheet.mask.x = 0; + this->spritesheet.mask.y = 0; } Animator::~Animator() { dbg_trace(); } @@ -51,6 +49,6 @@ void Animator::set_anim(int col) { void Animator::next_anim() { Animator::Data & ctx = this->data; - ctx.row = ctx.row++ % this->max_rows; + ctx.row = ctx.row++ % this->max_cell_size.x; this->spritesheet.mask.x = ctx.row * this->spritesheet.mask.w; } |