aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-30 16:44:47 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-30 16:44:47 +0100
commit1520cb55ad714583c3903f2988b0fdc38ede9c18 (patch)
tree49123f0f86eefc59e4cb9d12b87e67b2b9d62ab3 /src/crepe/system
parentad4f8acfb252b8be3a3fbb74ed97b32e498a26a4 (diff)
cleaner camera implementation
Diffstat (limited to 'src/crepe/system')
-rw-r--r--src/crepe/system/RenderSystem.cpp10
-rw-r--r--src/crepe/system/RenderSystem.h5
2 files changed, 6 insertions, 9 deletions
diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp
index c196bb1..944ac86 100644
--- a/src/crepe/system/RenderSystem.cpp
+++ b/src/crepe/system/RenderSystem.cpp
@@ -32,8 +32,8 @@ const Camera & RenderSystem::update_camera() {
if (!cam.active) continue;
const Transform & transform
= mgr.get_components_by_id<Transform>(cam.game_object_id).front().get();
- this->context.set_camera(cam);
- this->cam_pos = transform.position + cam.offset;
+ this->context.set_camera(cam, this->cam_ctx);
+ this->cam_ctx.cam_pos = transform.position + cam.offset;
return cam;
}
throw std::runtime_error("No active cameras in current scene");
@@ -79,8 +79,7 @@ bool RenderSystem::render_particle(const Sprite & sprite, const Camera & cam,
this->context.draw(SDLContext::RenderContext{
.sprite = sprite,
- .cam = cam,
- .cam_pos = this->cam_pos,
+ .cam = this->cam_ctx,
.pos = p.position,
.angle = p.angle,
.scale = scale,
@@ -93,8 +92,7 @@ void RenderSystem::render_normal(const Sprite & sprite, const Camera & cam,
const Transform & tm) {
this->context.draw(SDLContext::RenderContext{
.sprite = sprite,
- .cam = cam,
- .cam_pos = this->cam_pos,
+ .cam = this->cam_ctx,
.pos = tm.position,
.angle = tm.rotation,
.scale = tm.scale,
diff --git a/src/crepe/system/RenderSystem.h b/src/crepe/system/RenderSystem.h
index e70831e..9ff015e 100644
--- a/src/crepe/system/RenderSystem.h
+++ b/src/crepe/system/RenderSystem.h
@@ -76,9 +76,8 @@ private:
private:
SDLContext & context = SDLContext::get_instance();
-
- //! camera postion in the current scene
- vec2 cam_pos;
+
+ SDLContext::CameraValues cam_ctx;
};
} // namespace crepe