diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-11-27 11:08:50 +0100 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-11-27 11:08:50 +0100 |
commit | 72e605528ebe8347e1457358fe9025c215afe163 (patch) | |
tree | bd193e4805e7e600356f7d09a8971199cce8783b /src | |
parent | 3b433353a83c2436b69f73ca1048842d906b1147 (diff) |
implemented feedback, removed width so that user only can set height.
Diffstat (limited to 'src')
-rw-r--r-- | src/crepe/api/Animator.cpp | 2 | ||||
-rw-r--r-- | src/crepe/api/Sprite.cpp | 1 | ||||
-rw-r--r-- | src/crepe/api/Sprite.h | 2 | ||||
-rw-r--r-- | src/crepe/facade/SDLContext.cpp | 13 | ||||
-rw-r--r-- | src/example/rendering_particle.cpp | 2 |
5 files changed, 4 insertions, 16 deletions
diff --git a/src/crepe/api/Animator.cpp b/src/crepe/api/Animator.cpp index 0043896..b6540cf 100644 --- a/src/crepe/api/Animator.cpp +++ b/src/crepe/api/Animator.cpp @@ -22,6 +22,6 @@ Animator::Animator(game_object_id_t id, Sprite & ss, int row, int col, int col_a this->active = false; // need to do this for to get the aspect ratio for a single clipping in the spritesheet - this->spritesheet.aspect_ratio = (double) animator_rect.w / (double) animator_rect.h; + this->spritesheet.aspect_ratio = static_cast<double>(animator_rect.w) / animator_rect.h; } Animator::~Animator() { dbg_trace(); } diff --git a/src/crepe/api/Sprite.cpp b/src/crepe/api/Sprite.cpp index 27f219c..58e0884 100644 --- a/src/crepe/api/Sprite.cpp +++ b/src/crepe/api/Sprite.cpp @@ -2,7 +2,6 @@ #include <memory> #include "../util/Log.h" -#include "facade/SDLContext.h" #include "Component.h" #include "Sprite.h" diff --git a/src/crepe/api/Sprite.h b/src/crepe/api/Sprite.h index 89f9121..7d5f4c3 100644 --- a/src/crepe/api/Sprite.h +++ b/src/crepe/api/Sprite.h @@ -63,8 +63,6 @@ public: //! Order within the sorting layer uint8_t order_in_layer = 0; - //! width in world units - int width = 0; //! height in world units int height = 0; diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index 6e22316..abb3cb7 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -112,17 +112,8 @@ SDL_Rect SDLContext::get_src_rect(const Sprite & sprite) const { SDL_Rect SDLContext::get_dst_rect(const Sprite & sprite, const vec2 & pos, const Camera & cam, const double & img_scale) const { - int width, height; - - if (sprite.width > sprite.height) { - width = sprite.width; - height = sprite.width / sprite.aspect_ratio; - } else { - height = sprite.height; - width = sprite.height * sprite.aspect_ratio; - } - - cout << width << " " << height << " " << " " << sprite.aspect_ratio << endl; + int width = sprite.height * sprite.aspect_ratio; + int height = sprite.height; width *= img_scale * cam.zoom; height *= img_scale * cam.zoom; diff --git a/src/example/rendering_particle.cpp b/src/example/rendering_particle.cpp index 680c0ac..afa064d 100644 --- a/src/example/rendering_particle.cpp +++ b/src/example/rendering_particle.cpp @@ -35,10 +35,10 @@ int main(int argc, char * argv[]) { make_shared<Texture>("asset/texture/test_ap43.png"), color, FlipSettings{true, true}); test_sprite.order_in_layer = 5; - test_sprite.width = 259; test_sprite.height = 195; //game_object.add_component<Animator>(test_sprite, 4, 1, 0).active = true; + game_object.add_component<Animator>(test_sprite, 1, 1, 0).active = true; /* auto & test = game_object.add_component<ParticleEmitter>(ParticleEmitter::Data{ |