diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-12-18 19:17:38 +0100 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-12-18 19:17:38 +0100 |
commit | d0286486b5fddcfb32dcd1f3010aef5368ee678e (patch) | |
tree | b5d73c664ec0a1884dec4238eba866411d49d9d8 /src/crepe/system | |
parent | d8e6773be7206994716c29e1ee8195b10f094bdf (diff) |
rendering met absoluut position util functie, particle ben ik nog jaro aan het overleggen dus er die werkt niet goed
Diffstat (limited to 'src/crepe/system')
-rw-r--r-- | src/crepe/system/RenderSystem.cpp | 12 | ||||
-rw-r--r-- | src/crepe/system/RenderSystem.h | 2 |
2 files changed, 7 insertions, 7 deletions
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<Transform>(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; diff --git a/src/crepe/system/RenderSystem.h b/src/crepe/system/RenderSystem.h index d5385eb..762b11f 100644 --- a/src/crepe/system/RenderSystem.h +++ b/src/crepe/system/RenderSystem.h @@ -53,7 +53,7 @@ private: * constructor is now protected i cannot make tmp inside * \return true if particles have been rendered */ - bool render_particle(const Sprite & sprite, const double & scale); + bool render_particle(const Sprite & sprite, const Transform & tm); /** * \brief renders a sprite with a Transform component on the screen * |