From d0286486b5fddcfb32dcd1f3010aef5368ee678e Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Wed, 18 Dec 2024 19:17:38 +0100 Subject: rendering met absoluut position util functie, particle ben ik nog jaro aan het overleggen dus er die werkt niet goed --- src/crepe/system/RenderSystem.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/crepe/system/RenderSystem.cpp') diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp index bf2bfd3..ba09530 100644 --- a/src/crepe/system/RenderSystem.cpp +++ b/src/crepe/system/RenderSystem.cpp @@ -21,6 +21,7 @@ #include "RenderSystem.h" #include "types.h" +#include "util/AbsoluutPosition.h" using namespace crepe; using namespace std; @@ -99,8 +100,7 @@ void RenderSystem::render_text() { } } -bool RenderSystem::render_particle(const Sprite & sprite, const double & scale) { - +bool RenderSystem::render_particle(const Sprite & sprite, const Transform & tm){ ComponentManager & mgr = this->mediator.component_manager; SDLContext & ctx = this->mediator.sdl_context; ResourceManager & resource_manager = this->mediator.resource_manager; @@ -122,9 +122,9 @@ bool RenderSystem::render_particle(const Sprite & sprite, const double & scale) ctx.draw(SDLContext::RenderContext{ .sprite = sprite, .texture = res, - .pos = p.position, + .pos = AbsoluutPosition::get_position(tm, em.data.offset + sprite.data.position_offset), .angle = p.angle, - .scale = scale, + .scale = tm.scale, }); } } @@ -138,7 +138,7 @@ void RenderSystem::render_normal(const Sprite & sprite, const Transform & tm) { ctx.draw(SDLContext::RenderContext{ .sprite = sprite, .texture = res, - .pos = tm.position, + .pos = AbsoluutPosition::get_position(tm, sprite.data.position_offset), .angle = tm.rotation, .scale = tm.scale, }); @@ -158,7 +158,7 @@ void RenderSystem::render() { const Transform & transform = mgr.get_components_by_id(sprite.game_object_id).front().get(); - bool rendered_particles = this->render_particle(sprite, transform.scale); + bool rendered_particles = this->render_particle(sprite, transform); if (rendered_particles) continue; -- cgit v1.2.3