aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/RenderSystem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe/RenderSystem.cpp')
-rw-r--r--src/crepe/RenderSystem.cpp23
1 files changed, 12 insertions, 11 deletions
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 <cstddef>
#include <functional>
#include <vector>
@@ -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<std::reference_wrapper<Sprite>> sprites = mgr.get_components_by_type<Sprite>();
- std::vector<std::reference_wrapper<Transform>> transforms = mgr.get_components_by_type<Transform>();
+ ComponentManager & mgr = ComponentManager::get_instance();
- SdlContext& render = SdlContext::get_instance();
+ std::vector<std::reference_wrapper<Sprite>> sprites
+ = mgr.get_components_by_type<Sprite>();
+
+ 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<std::reference_wrapper<Transform>> transforms = mgr.get_components_by_id<Transform>(sprite.gameObjectId);
+ for (const Transform& transform : transforms) {
+ render.draw(sprite, transform);
+ }
+ }
render.present_screen();
-
}