aboutsummaryrefslogtreecommitdiff
path: root/src/crepe
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe')
-rw-r--r--src/crepe/api/Animator.cpp18
-rw-r--r--src/crepe/api/Animator.h12
-rw-r--r--src/crepe/api/CMakeLists.txt2
-rw-r--r--src/crepe/api/LoopManager.cpp1
-rw-r--r--src/crepe/facade/CMakeLists.txt2
-rw-r--r--src/crepe/facade/SDLContext.cpp4
-rw-r--r--src/crepe/facade/Texture.cpp (renamed from src/crepe/api/Texture.cpp)1
-rw-r--r--src/crepe/facade/Texture.h (renamed from src/crepe/api/Texture.h)5
-rw-r--r--src/crepe/system/AnimatorSystem.cpp2
-rw-r--r--src/crepe/system/RenderSystem.cpp5
10 files changed, 24 insertions, 28 deletions
diff --git a/src/crepe/api/Animator.cpp b/src/crepe/api/Animator.cpp
index ad1778d..4c72cc0 100644
--- a/src/crepe/api/Animator.cpp
+++ b/src/crepe/api/Animator.cpp
@@ -7,20 +7,18 @@
using namespace crepe;
-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)
+Animator::Animator(game_object_id_t id, Sprite & spritesheet, const ivec2 & single_frame_size,
+ const uvec2 & max_cell_size, const Animator::Data & data)
: Component(id),
spritesheet(spritesheet),
- max_rows(max_row),
- max_columns(max_col),
+ max_cell_size(max_cell_size),
data(data) {
dbg_trace();
- 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;
+ this->spritesheet.mask.w = single_frame_size.x;
+ this->spritesheet.mask.h = single_frame_size.y;
+ this->spritesheet.mask.x = 0;
+ this->spritesheet.mask.y = 0;
}
Animator::~Animator() { dbg_trace(); }
@@ -51,6 +49,6 @@ void Animator::set_anim(int col) {
void Animator::next_anim() {
Animator::Data & ctx = this->data;
- ctx.row = ctx.row++ % this->max_rows;
+ ctx.row = ctx.row++ % this->max_cell_size.x;
this->spritesheet.mask.x = ctx.row * this->spritesheet.mask.w;
}
diff --git a/src/crepe/api/Animator.h b/src/crepe/api/Animator.h
index 8ceddad..9a26bf0 100644
--- a/src/crepe/api/Animator.h
+++ b/src/crepe/api/Animator.h
@@ -82,16 +82,14 @@ public:
* This constructor sets up the Animator with the given parameters, and initializes the
* animation system.
*/
- 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);
+ Animator(game_object_id_t id, Sprite & spritesheet, const ivec2 & single_frame_size,
+ const uvec2 & max_cell_size, const Animator::Data & data);
~Animator(); // dbg_trace
public:
- //! The maximum number of columns in the sprite sheet.
- const unsigned int max_columns;
- //! The maximum number of rows in the sprite sheet.
- const unsigned int max_rows;
+ //! The maximum number of rows and columns size
+ const uvec2 max_cell_size;
+
Animator::Data data;
private:
diff --git a/src/crepe/api/CMakeLists.txt b/src/crepe/api/CMakeLists.txt
index a163faf..718e497 100644
--- a/src/crepe/api/CMakeLists.txt
+++ b/src/crepe/api/CMakeLists.txt
@@ -6,7 +6,6 @@ target_sources(crepe PUBLIC
ParticleEmitter.cpp
Transform.cpp
Color.cpp
- Texture.cpp
Sprite.cpp
Config.cpp
Metadata.cpp
@@ -38,7 +37,6 @@ target_sources(crepe PUBLIC FILE_SET HEADERS FILES
Vector2.h
Vector2.hpp
Color.h
- Texture.h
Scene.h
Metadata.h
Camera.h
diff --git a/src/crepe/api/LoopManager.cpp b/src/crepe/api/LoopManager.cpp
index 044f096..88243c4 100644
--- a/src/crepe/api/LoopManager.cpp
+++ b/src/crepe/api/LoopManager.cpp
@@ -65,7 +65,6 @@ void LoopManager::setup() {
this->scene_manager.load_next_scene();
timer.start();
timer.set_fps(200);
- this->scene_manager.load_next_scene();
}
void LoopManager::render() {
diff --git a/src/crepe/facade/CMakeLists.txt b/src/crepe/facade/CMakeLists.txt
index 4cc53bc..0598e16 100644
--- a/src/crepe/facade/CMakeLists.txt
+++ b/src/crepe/facade/CMakeLists.txt
@@ -1,5 +1,6 @@
target_sources(crepe PUBLIC
Sound.cpp
+ Texture.cpp
SoundContext.cpp
SDLContext.cpp
DB.cpp
@@ -7,6 +8,7 @@ target_sources(crepe PUBLIC
target_sources(crepe PUBLIC FILE_SET HEADERS FILES
Sound.h
+ Texture.h
SoundContext.h
SDLContext.h
DB.h
diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp
index ac21d15..a92ec8b 100644
--- a/src/crepe/facade/SDLContext.cpp
+++ b/src/crepe/facade/SDLContext.cpp
@@ -19,12 +19,12 @@
#include "../api/Color.h"
#include "../api/Config.h"
#include "../api/Sprite.h"
-#include "../api/Texture.h"
#include "../util/Log.h"
#include "manager/Manager.h"
#include "manager/Mediator.h"
#include "SDLContext.h"
+#include "Texture.h"
#include "types.h"
using namespace crepe;
@@ -273,7 +273,7 @@ void SDLContext::draw(const RenderContext & ctx) {
.img_scale = ctx.scale,
});
- cout << dstrect.w << " " << dstrect.h << " " << dstrect.x << " " << dstrect.y << endl;
+ cout << srcrect->w << " " << srcrect->h << " " << srcrect->x << " " << srcrect->y << endl;
double angle = ctx.angle + data.angle_offset;
this->set_color_texture(ctx.texture, ctx.sprite.data.color);
diff --git a/src/crepe/api/Texture.cpp b/src/crepe/facade/Texture.cpp
index b0863cb..7224cb8 100644
--- a/src/crepe/api/Texture.cpp
+++ b/src/crepe/facade/Texture.cpp
@@ -2,7 +2,6 @@
#include "manager/Mediator.h"
#include "facade/SDLContext.h"
-#include "Asset.h"
#include "Resource.h"
#include "Texture.h"
#include "types.h"
diff --git a/src/crepe/api/Texture.h b/src/crepe/facade/Texture.h
index c33d9e5..255e14b 100644
--- a/src/crepe/api/Texture.h
+++ b/src/crepe/facade/Texture.h
@@ -6,13 +6,14 @@
#include <SDL2/SDL_render.h>
#include <memory>
-#include "Asset.h"
-#include "Resource.h"
+#include "../Resource.h"
+
#include "types.h"
namespace crepe {
class Mediator;
+class Asset;
/**
* \class Texture
diff --git a/src/crepe/system/AnimatorSystem.cpp b/src/crepe/system/AnimatorSystem.cpp
index 549c35d..bb22b62 100644
--- a/src/crepe/system/AnimatorSystem.cpp
+++ b/src/crepe/system/AnimatorSystem.cpp
@@ -23,7 +23,7 @@ void AnimatorSystem::update() {
int last_frame = ctx.row;
- int cycle_end = (ctx.cycle_end == -1) ? a.max_rows : ctx.cycle_end;
+ int cycle_end = (ctx.cycle_end == -1) ? a.max_cell_size.x : ctx.cycle_end;
int total_frames = cycle_end - ctx.cycle_start;
int curr_frame = static_cast<int>(elapsed_time / frame_duration) % total_frames;
diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp
index daf71c5..51340fb 100644
--- a/src/crepe/system/RenderSystem.cpp
+++ b/src/crepe/system/RenderSystem.cpp
@@ -10,9 +10,10 @@
#include "../api/Sprite.h"
#include "../api/Transform.h"
#include "../facade/SDLContext.h"
+#include "../facade/Texture.h"
#include "../manager/ComponentManager.h"
-#include "api/Texture.h"
-#include "manager/ResourceManager.h"
+#include "../manager/ResourceManager.h"
+
#include "RenderSystem.h"
using namespace crepe;