aboutsummaryrefslogtreecommitdiff
path: root/src/crepe
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-18 14:19:06 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-18 14:19:06 +0100
commitd1f379b8f8b157f0ba4c95940e221fc58463d942 (patch)
tree661d857d386034c5d7d40f4da96e35c10ffa467b /src/crepe
parent20fc8401083e23e414feae2a9a4d217b228b8f15 (diff)
merged master
Diffstat (limited to 'src/crepe')
-rw-r--r--src/crepe/system/RenderSystem.cpp18
-rw-r--r--src/crepe/system/RenderSystem.h7
2 files changed, 12 insertions, 13 deletions
diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp
index 52dd5fc..4abd9bd 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 ebad05d..6126dfe 100644
--- a/src/crepe/system/RenderSystem.h
+++ b/src/crepe/system/RenderSystem.h
@@ -42,10 +42,13 @@ private:
* \brief Renders all the particles on the screen from a given sprite.
*
* \param sprite renders the particles with given texture
- * \param tm the Transform component for scale
+ * \param tm the Transform component for scale. This is not a const reference because each
+ * particle has a position and rotation that needs to overwrite the transform position and
+ * rotation without overwriting the current transform. and because the transform
+ * constructor is now protected i cannot make tmp inside
* \return true if particles have been rendered
*/
- bool render_particle(const Sprite &, const Transform & tm);
+ bool render_particle(const Sprite &, Transform tm);
void render_normal(const Sprite &, const Transform & tm);