diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-12-18 11:31:54 +0100 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-12-18 11:31:54 +0100 |
commit | ea5e62b4ca8fbe214605abdab486bf6dcc1cc540 (patch) | |
tree | db8eaad14aad977e8b5d82ff8ae1c6f4a757430e /src/crepe/system | |
parent | 81404db80bbf9463c3d535ae389e7fbb753a902c (diff) |
added particle begin lifespan rendering, added world_space to sprite so that coordinates are in camera_space or world_sapce
Diffstat (limited to 'src/crepe/system')
-rw-r--r-- | src/crepe/system/RenderSystem.cpp | 9 | ||||
-rw-r--r-- | src/crepe/system/RenderSystem.h | 3 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp index 62d42ec..57d180f 100644 --- a/src/crepe/system/RenderSystem.cpp +++ b/src/crepe/system/RenderSystem.cpp @@ -73,7 +73,8 @@ void RenderSystem::update() { this->present_screen(); } -bool RenderSystem::render_particle(const Sprite & sprite, const double & scale) { +bool RenderSystem::render_particle(const Sprite & sprite, const float & transform_angle, + const float & scale) { ComponentManager & mgr = this->mediator.component_manager; SDLContext & ctx = this->mediator.sdl_context; @@ -92,12 +93,13 @@ bool RenderSystem::render_particle(const Sprite & sprite, const double & scale) for (const Particle & p : em.particles) { if (!p.active) continue; + if (p.time_in_life < em.data.begin_lifespan) continue; ctx.draw(SDLContext::RenderContext{ .sprite = sprite, .texture = res, .pos = p.position, - .angle = p.angle, + .angle = p.angle + transform_angle, .scale = scale, }); } @@ -136,7 +138,8 @@ 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.rotation, transform.scale); if (rendered_particles) continue; diff --git a/src/crepe/system/RenderSystem.h b/src/crepe/system/RenderSystem.h index 56a0553..76df0e0 100644 --- a/src/crepe/system/RenderSystem.h +++ b/src/crepe/system/RenderSystem.h @@ -49,7 +49,8 @@ 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 float & transform_angle, + const float & scale); /** * \brief Renders all Text components * |