aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-18 15:18:20 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-18 15:18:20 +0100
commit74fcf733c2bcdcbcbfc64d88270b12a39e9d91e0 (patch)
tree4288ff8e76c4412b068e80c0d06f258d126593a1
parentfee42c67918a9370f7f4e074dba9a677afccf90b (diff)
merged master
-rw-r--r--src/crepe/system/RenderSystem.cpp18
-rw-r--r--src/crepe/system/RenderSystem.h2
2 files changed, 8 insertions, 12 deletions
diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp
index 23ab738..37320ed 100644
--- a/src/crepe/system/RenderSystem.cpp
+++ b/src/crepe/system/RenderSystem.cpp
@@ -6,11 +6,9 @@
#include "../api/Sprite.h"
#include "../api/Transform.h"
#include "../facade/SDLContext.h"
-#include "../util/log.h"
#include "../api/ParticleEmitter.h"
#include "../api/Vector2.h"
-#include "Particle.h"
#include "RenderSystem.h"
using namespace crepe;
@@ -30,17 +28,15 @@ void RenderSystem::update_camera() {
}
bool RenderSystem::render_particle(const Sprite & sprite,
- const Transform & tm) {
+ Transform tm) {
- ComponentManager & mgr = ComponentManager::get_instance();
+ ComponentManager & mgr = this->component_manager;
SDLContext & render = SDLContext::get_instance();
auto emitters = mgr.get_components_by_id<ParticleEmitter>(sprite.game_object_id);
bool rendering_particles = false;
- Transform tmp(0, Vector2{0, 0}, 0, 0);
- tmp.scale = tm.scale;
for (const ParticleEmitter & em : emitters) {
if (!em.active) continue;
if (!(em.data.sprite.game_object_id == sprite.game_object_id)) continue;
@@ -49,16 +45,16 @@ bool RenderSystem::render_particle(const Sprite & sprite,
for (const Particle & p : em.data.particles) {
if (!p.active) continue;
- tmp.position = p.position;
- tmp.rotation = p.angle;
- render.draw(em.data.sprite, tmp, *curr_cam);
+ tm.position = p.position;
+ tm.rotation = p.angle;
+ render.draw(em.data.sprite, tm, *curr_cam);
}
}
return rendering_particles;
}
void RenderSystem::render_normal(const Sprite & sprite, const Transform & tm) {
- ComponentManager & mgr = ComponentManager::get_instance();
+ ComponentManager & mgr = this->component_manager;
SDLContext & render = SDLContext::get_instance();
render.draw(sprite, tm, *curr_cam);
@@ -66,7 +62,7 @@ void RenderSystem::render_normal(const Sprite & sprite, const Transform & tm) {
void RenderSystem::render() {
- ComponentManager & mgr = ComponentManager::get_instance();
+ ComponentManager & mgr = this->component_manager;
auto sprites = mgr.get_components_by_type<Sprite>();
for (const Sprite & sprite : sprites) {
diff --git a/src/crepe/system/RenderSystem.h b/src/crepe/system/RenderSystem.h
index ad44716..c18b80b 100644
--- a/src/crepe/system/RenderSystem.h
+++ b/src/crepe/system/RenderSystem.h
@@ -51,7 +51,7 @@ private:
* \param tm the Transform component for scale
* \return true if particles have been rendered
*/
- bool render_particle(const Sprite &, const Transform & tm);
+ bool render_particle(const Sprite &, Transform tm);
/**
* \brief renders a sprite with a Transform component on the screen