aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system/RenderSystem.cpp
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-08 11:44:21 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-08 11:44:21 +0100
commit9432900158e6a31815345fcf0af8d28ae34c6da9 (patch)
tree36f799da46ba8f5e921349d0f004b08d6d2f29ea /src/crepe/system/RenderSystem.cpp
parent1c4156ee127b14760ed3b1a0cd16ad12180c7ac6 (diff)
code style
Diffstat (limited to 'src/crepe/system/RenderSystem.cpp')
-rw-r--r--src/crepe/system/RenderSystem.cpp35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp
index 5a07cc2..149af68 100644
--- a/src/crepe/system/RenderSystem.cpp
+++ b/src/crepe/system/RenderSystem.cpp
@@ -20,7 +20,23 @@ RenderSystem & RenderSystem::get_instance() {
return instance;
}
-void RenderSystem::update() {
+void RenderSystem::clear_screen() { SDLContext::get_instance().clear_screen(); }
+
+void RenderSystem::present_screen() {
+ SDLContext::get_instance().present_screen();
+}
+void RenderSystem::update_camera() {
+ ComponentManager & mgr = ComponentManager::get_instance();
+
+ std::vector<std::reference_wrapper<Camera>> cameras
+ = mgr.get_components_by_type<Camera>();
+
+ for (Camera & cam : cameras) {
+ SDLContext::get_instance().camera(cam);
+ this->curr_cam = &cam;
+ }
+}
+void RenderSystem::render_sprites() {
ComponentManager & mgr = ComponentManager::get_instance();
@@ -28,14 +44,15 @@ void RenderSystem::update() {
= mgr.get_components_by_type<Sprite>();
SDLContext & render = SDLContext::get_instance();
- render.clear_screen();
-
for (const Sprite & sprite : sprites) {
- std::vector<std::reference_wrapper<Transform>> transforms
- = mgr.get_components_by_id<Transform>(sprite.game_object_id);
- for (const Transform & transform : transforms) {
- render.draw(sprite, transform);
- }
+ auto transforms = mgr.get_components_by_id<Transform>(sprite.game_object_id);
+ render.draw(sprite, transforms[0] , *curr_cam);
}
- render.present_screen();
+}
+
+void RenderSystem::update() {
+ this->clear_screen();
+ this->update_camera();
+ this->render_sprites();
+ this->present_screen();
}