aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api/Animator.cpp
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-09 15:35:36 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-09 15:35:36 +0100
commit33cd5566909ac089cdf56db38a3d1daf0cb7dd10 (patch)
tree1d684595d5e8ef88c6c874ced36e616786231dd0 /src/crepe/api/Animator.cpp
parent519cc5d16e65ff501d330c03eeb35d2d095ead29 (diff)
fixed the aspect ratio and removed the ratio from sprite and give it to texture. however the problem still lies with if animator is given the aspect ratio is then off
Diffstat (limited to 'src/crepe/api/Animator.cpp')
-rw-r--r--src/crepe/api/Animator.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/crepe/api/Animator.cpp b/src/crepe/api/Animator.cpp
index b8a91dc..ad1778d 100644
--- a/src/crepe/api/Animator.cpp
+++ b/src/crepe/api/Animator.cpp
@@ -7,8 +7,9 @@
using namespace crepe;
-Animator::Animator(game_object_id_t id, Sprite & spritesheet, unsigned int max_row,
- unsigned int max_col, const Animator::Data & data)
+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)
: Component(id),
spritesheet(spritesheet),
max_rows(max_row),
@@ -16,14 +17,10 @@ Animator::Animator(game_object_id_t id, Sprite & spritesheet, unsigned int max_r
data(data) {
dbg_trace();
- this->spritesheet.mask.h /= this->max_columns;
- this->spritesheet.mask.w /= this->max_rows;
+ 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;
-
- // 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;
}
Animator::~Animator() { dbg_trace(); }