aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-08 14:29:25 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-08 14:29:25 +0100
commit63bcd54e0e0ea64cfef5950568b4253d5dae5c1e (patch)
tree24f1f251259ca46566a4694b765dc4e99ee264ab /src/crepe/system
parent5c3ce63558f2d5dec06a124773f910d783bb22aa (diff)
removed singleton from SDLContext, problem now is cannot call functionalities in the constructor sprite and animator and texture because it can only be filled at rendersystem call
Diffstat (limited to 'src/crepe/system')
-rw-r--r--src/crepe/system/InputSystem.cpp6
-rw-r--r--src/crepe/system/RenderSystem.cpp11
2 files changed, 16 insertions, 1 deletions
diff --git a/src/crepe/system/InputSystem.cpp b/src/crepe/system/InputSystem.cpp
index aaa8bdf..b36ec09 100644
--- a/src/crepe/system/InputSystem.cpp
+++ b/src/crepe/system/InputSystem.cpp
@@ -1,15 +1,19 @@
#include "../api/Button.h"
#include "../manager/ComponentManager.h"
#include "../manager/EventManager.h"
+#include "facade/SDLContext.h"
+#include "util/Log.h"
#include "InputSystem.h"
using namespace crepe;
void InputSystem::update() {
+ dbg_trace();
ComponentManager & mgr = this->mediator.component_manager;
EventManager & event_mgr = this->mediator.event_manager;
- std::vector<SDLContext::EventData> event_list = SDLContext::get_instance().get_events();
+ SDLContext & context = this->mediator.sdl_context;
+ std::vector<SDLContext::EventData> event_list = context.get_events();
RefVector<Button> buttons = mgr.get_components_by_type<Button>();
RefVector<Camera> cameras = mgr.get_components_by_type<Camera>();
OptionalRef<Camera> curr_cam_ref;
diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp
index 26f2c85..d81d8dd 100644
--- a/src/crepe/system/RenderSystem.cpp
+++ b/src/crepe/system/RenderSystem.cpp
@@ -11,6 +11,9 @@
#include "../api/Transform.h"
#include "../facade/SDLContext.h"
#include "../manager/ComponentManager.h"
+#include "api/Texture.h"
+#include "manager/ResourceManager.h"
+#include "util/Log.h"
#include "RenderSystem.h"
@@ -62,6 +65,7 @@ RefVector<Sprite> RenderSystem::sort(RefVector<Sprite> & objs) const {
}
void RenderSystem::update() {
+ dbg_trace();
this->clear_screen();
this->render();
this->present_screen();
@@ -72,6 +76,8 @@ bool RenderSystem::render_particle(const Sprite & sprite, const SDLContext::Came
ComponentManager & mgr = this->mediator.component_manager;
SDLContext & ctx = this->mediator.sdl_context;
+ ResourceManager & resource_manager = this->mediator.resource_manager;
+ Texture & res = resource_manager.get<Texture>(sprite.source);
vector<reference_wrapper<ParticleEmitter>> emitters
= mgr.get_components_by_id<ParticleEmitter>(sprite.game_object_id);
@@ -88,6 +94,7 @@ bool RenderSystem::render_particle(const Sprite & sprite, const SDLContext::Came
ctx.draw(SDLContext::RenderContext{
.sprite = sprite,
+ .texture = res,
.cam = cam,
.pos = p.position,
.angle = p.angle,
@@ -100,8 +107,12 @@ bool RenderSystem::render_particle(const Sprite & sprite, const SDLContext::Came
void RenderSystem::render_normal(const Sprite & sprite, const SDLContext::CameraValues & cam,
const Transform & tm) {
SDLContext & ctx = this->mediator.sdl_context;
+ ResourceManager & resource_manager = this->mediator.resource_manager;
+ Texture & res = resource_manager.get<Texture>(sprite.source);
+
ctx.draw(SDLContext::RenderContext{
.sprite = sprite,
+ .texture = res,
.cam = cam,
.pos = tm.position,
.angle = tm.rotation,