aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-28 09:18:13 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-28 09:18:13 +0100
commit71be3e36dbb402c3e84d87ea0255c08cb2a1b7ca (patch)
tree25a26be197fe64d2e4411ee0db1568fb6eb0b6f5 /src/crepe/system
parent5fa57ab2d8f809b8cb6bd72f54567a01f3e63b95 (diff)
implemented feedback to have draw struct
Diffstat (limited to 'src/crepe/system')
-rw-r--r--src/crepe/system/RenderSystem.cpp25
-rw-r--r--src/crepe/system/RenderSystem.h6
2 files changed, 28 insertions, 3 deletions
diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp
index a1443cd..bfee658 100644
--- a/src/crepe/system/RenderSystem.cpp
+++ b/src/crepe/system/RenderSystem.cpp
@@ -11,6 +11,7 @@
#include "../api/Transform.h"
#include "../facade/SDLContext.h"
#include "api/Camera.h"
+#include "types.h"
#include "RenderSystem.h"
@@ -33,7 +34,7 @@ const Camera & RenderSystem::update_camera() {
const Transform & transform
= mgr.get_components_by_id<Transform>(cam.game_object_id).front().get();
this->context.set_camera(cam);
- cam.pos = transform.position + cam.offset;
+ this->cam_pos = transform.position + cam.offset;
return cam;
}
throw std::runtime_error("No active cameras in current scene");
@@ -76,14 +77,32 @@ bool RenderSystem::render_particle(const Sprite & sprite, const Camera & cam,
for (const Particle & p : em.data.particles) {
if (!p.active) continue;
- this->context.draw_particle(sprite, p.position, p.angle, scale, cam);
+
+ RenderCtx ctx{
+ .sprite = sprite,
+ .cam = cam,
+ .cam_pos = this->cam_pos,
+ .pos = p.position,
+ .angle = p.angle,
+ .scale = scale,
+ };
+ this->context.draw(ctx);
}
}
return rendering_particles;
}
void RenderSystem::render_normal(const Sprite & sprite, const Camera & cam,
const Transform & tm) {
- this->context.draw(sprite, tm, cam);
+
+ RenderCtx ctx{
+ .sprite = sprite,
+ .cam = cam,
+ .cam_pos = this->cam_pos,
+ .pos = tm.position,
+ .angle = tm.rotation,
+ .scale = tm.scale,
+ };
+ this->context.draw(ctx);
}
void RenderSystem::render() {
diff --git a/src/crepe/system/RenderSystem.h b/src/crepe/system/RenderSystem.h
index 46ebb92..4667424 100644
--- a/src/crepe/system/RenderSystem.h
+++ b/src/crepe/system/RenderSystem.h
@@ -11,6 +11,8 @@ namespace crepe {
class Camera;
class Sprite;
+class Transform;
+
/**
* \class RenderSystem
@@ -75,6 +77,10 @@ private:
private:
SDLContext & context = SDLContext::get_instance();
+
+ //! camera postion in the current scene
+ vec2 cam_pos = {0,0};
+
};
} // namespace crepe