aboutsummaryrefslogtreecommitdiff
path: root/src/crepe
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-28 10:04:14 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-28 10:04:14 +0100
commit2d623522db0677ca5e88a53e3705a10ce59ba8b6 (patch)
treedd5acb4f0ab54e6f0e284181d9ee51e5ba4a7ce6 /src/crepe
parent71be3e36dbb402c3e84d87ea0255c08cb2a1b7ca (diff)
removed animator rectangle
Diffstat (limited to 'src/crepe')
-rw-r--r--src/crepe/api/Animator.cpp11
-rw-r--r--src/crepe/api/Animator.h2
-rw-r--r--src/crepe/api/Camera.h6
-rw-r--r--src/crepe/system/AnimatorSystem.cpp11
-rw-r--r--src/crepe/system/RenderSystem.h2
5 files changed, 14 insertions, 18 deletions
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<double>(animator_rect.w) / animator_rect.h;
+ this->spritesheet.aspect_ratio = static_cast<double>(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;
};