From ddb5bde6e5dd4d89faf419630086ece66690d6b5 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Wed, 27 Nov 2024 19:57:16 +0100 Subject: implemented feedback. biggest changes are teh camera_ref removed --- src/crepe/api/Animator.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/crepe/api/Animator.h') diff --git a/src/crepe/api/Animator.h b/src/crepe/api/Animator.h index 53f4b91..7a5ef03 100644 --- a/src/crepe/api/Animator.h +++ b/src/crepe/api/Animator.h @@ -40,11 +40,6 @@ public: Animator(uint32_t id, Sprite & spritesheet, int row, int col, int col_animate); ~Animator(); // dbg_trace - Animator(const Animator &) = delete; - Animator(Animator &&) = delete; - Animator & operator=(const Animator &) = delete; - Animator & operator=(Animator &&) = delete; - private: //! A reference to the Sprite sheet containing the animation frames. Sprite & spritesheet; -- cgit v1.2.3 From 43695ecee65d63ba89bdab3eb49b5ada0eef399f Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Thu, 28 Nov 2024 07:54:04 +0100 Subject: make format --- src/crepe/api/Animator.h | 1 + src/crepe/api/Camera.cpp | 2 +- src/crepe/api/Camera.h | 3 ++- src/crepe/api/Sprite.h | 1 + src/crepe/facade/SDLContext.cpp | 2 +- src/crepe/system/RenderSystem.h | 1 - 6 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/crepe/api/Animator.h') diff --git a/src/crepe/api/Animator.h b/src/crepe/api/Animator.h index 7a5ef03..19c9ebd 100644 --- a/src/crepe/api/Animator.h +++ b/src/crepe/api/Animator.h @@ -40,6 +40,7 @@ public: Animator(uint32_t id, Sprite & spritesheet, int row, int col, int col_animate); ~Animator(); // dbg_trace + private: //! A reference to the Sprite sheet containing the animation frames. Sprite & spritesheet; diff --git a/src/crepe/api/Camera.cpp b/src/crepe/api/Camera.cpp index 99a0831..0831f45 100644 --- a/src/crepe/api/Camera.cpp +++ b/src/crepe/api/Camera.cpp @@ -8,7 +8,7 @@ using namespace crepe; Camera::Camera(game_object_id_t id, const Color & bg_color, const ivec2 & screen, - const ivec2 & viewport, const double & zoom, const vec2& offset) + const ivec2 & viewport, const double & zoom, const vec2 & offset) : Component(id), bg_color(bg_color), offset(offset), diff --git a/src/crepe/api/Camera.h b/src/crepe/api/Camera.h index 8908caa..c7b2d08 100644 --- a/src/crepe/api/Camera.h +++ b/src/crepe/api/Camera.h @@ -21,7 +21,8 @@ public: * \param id Unique identifier for the camera component. * \param bg_color Background color for the camera view. */ - Camera(game_object_id_t id, const Color & bg_color, const ivec2 & screen, const ivec2 & viewport, const double & zoom, const vec2 & offset = {0,0}); + Camera(game_object_id_t id, const Color & bg_color, const ivec2 & screen, + const ivec2 & viewport, const double & zoom, const vec2 & offset = {0, 0}); ~Camera(); // dbg_trace only public: diff --git a/src/crepe/api/Sprite.h b/src/crepe/api/Sprite.h index 9644e72..c406b91 100644 --- a/src/crepe/api/Sprite.h +++ b/src/crepe/api/Sprite.h @@ -77,6 +77,7 @@ public: * does it need to be calculated again in the Animator */ double aspect_ratio; + private: //! Reads the sprite_rect of sprite friend class SDLContext; diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index 6c6af55..0d42a4c 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -12,10 +12,10 @@ #include #include "../api/Camera.h" +#include "../api/Config.h" #include "../api/Sprite.h" #include "../api/Texture.h" #include "../api/Transform.h" -#include "../api/Config.h" #include "../util/Log.h" #include "SDLContext.h" diff --git a/src/crepe/system/RenderSystem.h b/src/crepe/system/RenderSystem.h index 264dc4c..46ebb92 100644 --- a/src/crepe/system/RenderSystem.h +++ b/src/crepe/system/RenderSystem.h @@ -75,7 +75,6 @@ private: private: SDLContext & context = SDLContext::get_instance(); - }; } // namespace crepe -- cgit v1.2.3 From 2d623522db0677ca5e88a53e3705a10ce59ba8b6 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Thu, 28 Nov 2024 10:04:14 +0100 Subject: removed animator rectangle --- src/crepe/api/Animator.cpp | 11 +++++------ src/crepe/api/Animator.h | 2 -- src/crepe/api/Camera.h | 6 +++--- src/crepe/system/AnimatorSystem.cpp | 11 +++++------ src/crepe/system/RenderSystem.h | 2 +- 5 files changed, 14 insertions(+), 18 deletions(-) (limited to 'src/crepe/api/Animator.h') diff --git a/src/crepe/api/Animator.cpp b/src/crepe/api/Animator.cpp index b6540cf..31b9632 100644 --- a/src/crepe/api/Animator.cpp +++ b/src/crepe/api/Animator.cpp @@ -14,14 +14,13 @@ Animator::Animator(game_object_id_t id, Sprite & ss, int row, int col, int col_a col(col) { dbg_trace(); - animator_rect = spritesheet.sprite_rect; - animator_rect.h /= col; - animator_rect.w /= row; - animator_rect.x = 0; - animator_rect.y = col_animator * animator_rect.h; + this->spritesheet.sprite_rect.h /= col; + this->spritesheet.sprite_rect.w /= row; + this->spritesheet.sprite_rect.x = 0; + this->spritesheet.sprite_rect.y = col_animator * this->spritesheet.sprite_rect.h; this->active = false; // need to do this for to get the aspect ratio for a single clipping in the spritesheet - this->spritesheet.aspect_ratio = static_cast(animator_rect.w) / animator_rect.h; + this->spritesheet.aspect_ratio = static_cast(this->spritesheet.sprite_rect.w) / this->spritesheet.sprite_rect.h; } Animator::~Animator() { dbg_trace(); } diff --git a/src/crepe/api/Animator.h b/src/crepe/api/Animator.h index 19c9ebd..6c506aa 100644 --- a/src/crepe/api/Animator.h +++ b/src/crepe/api/Animator.h @@ -57,8 +57,6 @@ private: //! The current row being animated. int curr_row = 0; - Rect animator_rect; - //TODO: Is this necessary? //int fps; diff --git a/src/crepe/api/Camera.h b/src/crepe/api/Camera.h index ac56495..3682222 100644 --- a/src/crepe/api/Camera.h +++ b/src/crepe/api/Camera.h @@ -33,13 +33,13 @@ public: vec2 offset; //! screen the display size in pixels ( output resolution ) - const ivec2 screen = {1080, 720}; + const ivec2 screen; //! viewport is the area of the world visible through the camera (in world units) - const ivec2 viewport = {500, 1000}; + const ivec2 viewport; //! Zoom level of the camera view. - const double zoom = 1.0f; + const double zoom; public: /** diff --git a/src/crepe/system/AnimatorSystem.cpp b/src/crepe/system/AnimatorSystem.cpp index bc94253..e5b277f 100644 --- a/src/crepe/system/AnimatorSystem.cpp +++ b/src/crepe/system/AnimatorSystem.cpp @@ -15,11 +15,10 @@ void AnimatorSystem::update() { uint64_t tick = SDLContext::get_instance().get_ticks(); for (Animator & a : animations) { - if (a.active) { - // (10 frames per second) - a.curr_row = (tick / 100) % a.row; - a.animator_rect.x = (a.curr_row * a.animator_rect.w) + a.curr_col; - a.spritesheet.sprite_rect = a.animator_rect; - } + if (!a.active) continue; + // (10 frames per second) + a.curr_row = (tick / 100) % a.row; + a.spritesheet.sprite_rect.x = (a.curr_row * a.spritesheet.sprite_rect.w) + a.curr_col; + a.spritesheet.sprite_rect = a.spritesheet.sprite_rect; } } diff --git a/src/crepe/system/RenderSystem.h b/src/crepe/system/RenderSystem.h index 4667424..7279b5c 100644 --- a/src/crepe/system/RenderSystem.h +++ b/src/crepe/system/RenderSystem.h @@ -79,7 +79,7 @@ private: SDLContext & context = SDLContext::get_instance(); //! camera postion in the current scene - vec2 cam_pos = {0,0}; + vec2 cam_pos; }; -- cgit v1.2.3