From c9246515fe785563411e9170aedd0231165ab988 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Wed, 23 Oct 2024 19:56:28 +0200 Subject: rendering and assetmanager --- src/crepe/RenderSystem.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/crepe/RenderSystem.cpp') diff --git a/src/crepe/RenderSystem.cpp b/src/crepe/RenderSystem.cpp index 6aae3bb..b5503d3 100644 --- a/src/crepe/RenderSystem.cpp +++ b/src/crepe/RenderSystem.cpp @@ -6,7 +6,6 @@ #include "api/Sprite.h" #include "api/Transform.h" #include "util/log.h" -#include #include #include @@ -17,25 +16,27 @@ RenderSystem::RenderSystem() { dbg_trace(); } RenderSystem::~RenderSystem() { dbg_trace(); } -RenderSystem& RenderSystem::get_instance(){ +RenderSystem & RenderSystem::get_instance() { static RenderSystem instance; return instance; } void RenderSystem::update() { - ComponentManager& mgr = ComponentManager::get_instance(); - - std::vector> sprites = mgr.get_components_by_type(); - std::vector> transforms = mgr.get_components_by_type(); + ComponentManager & mgr = ComponentManager::get_instance(); - SdlContext& render = SdlContext::get_instance(); + std::vector> sprites + = mgr.get_components_by_type(); + + SdlContext & render = SdlContext::get_instance(); render.clear_screen(); - for (size_t i = 0; i < sprites.size(); ++i) { - render.draw(sprites[i].get(), transforms[i].get()); - } + for (const Sprite & sprite : sprites) { + std::vector> transforms = mgr.get_components_by_id(sprite.gameObjectId); + for (const Transform& transform : transforms) { + render.draw(sprite, transform); + } + } render.present_screen(); - } -- cgit v1.2.3