From 33cd5566909ac089cdf56db38a3d1daf0cb7dd10 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Mon, 9 Dec 2024 15:35:36 +0100 Subject: 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 --- src/crepe/api/Animator.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/crepe/api/Animator.cpp') 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(this->spritesheet.mask.w) / this->spritesheet.mask.h; } Animator::~Animator() { dbg_trace(); } -- cgit v1.2.3