aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system
diff options
context:
space:
mode:
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