aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-20 14:06:54 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-20 14:06:54 +0100
commit3344e0df01435be903e38ccbd3b9cee608d574e7 (patch)
tree949a3a2d28ce143621f9da90aaea5361d95f9074 /src/crepe/system
parent158022890cb9abd308a6a445588cc2fca8d84e67 (diff)
implemented feedback
Diffstat (limited to 'src/crepe/system')
-rw-r--r--src/crepe/system/RenderSystem.cpp18
-rw-r--r--src/crepe/system/RenderSystem.h14
2 files changed, 13 insertions, 19 deletions
diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp
index 1ae5ca7..28bcf56 100644
--- a/src/crepe/system/RenderSystem.cpp
+++ b/src/crepe/system/RenderSystem.cpp
@@ -2,11 +2,11 @@
#include <vector>
#include "../ComponentManager.h"
+#include "../api/ParticleEmitter.h"
#include "../api/Sprite.h"
#include "../api/Transform.h"
-#include "../facade/SDLContext.h"
-#include "../api/ParticleEmitter.h"
#include "../api/Vector2.h"
+#include "../facade/SDLContext.h"
#include "RenderSystem.h"
@@ -21,13 +21,12 @@ void RenderSystem::update_camera() {
auto cameras = mgr.get_components_by_type<Camera>();
for (Camera & cam : cameras) {
- SDLContext::get_instance().camera(cam);
+ SDLContext::get_instance().set_camera(cam);
this->curr_cam = &cam;
}
}
-bool RenderSystem::render_particle(const Sprite & sprite,
- const double & scale) {
+bool RenderSystem::render_particle(const Sprite & sprite, const double & scale) const {
ComponentManager & mgr = this->component_manager;
SDLContext & render = SDLContext::get_instance();
@@ -49,22 +48,23 @@ bool RenderSystem::render_particle(const Sprite & sprite,
}
return rendering_particles;
}
-void RenderSystem::render_normal(const Sprite & sprite, const Transform & tm) {
+void RenderSystem::render_normal(const Sprite & sprite, const Transform & tm) const {
ComponentManager & mgr = this->component_manager;
SDLContext & render = SDLContext::get_instance();
-
+
render.draw(sprite, tm, *curr_cam);
}
-void RenderSystem::render() {
+void RenderSystem::render() const {
ComponentManager & mgr = this->component_manager;
auto sprites = mgr.get_components_by_type<Sprite>();
for (const Sprite & sprite : sprites) {
if (!sprite.active) continue;
- auto transform = mgr.get_components_by_id<Transform>(sprite.game_object_id).front().get();
+ const Transform & transform
+ = mgr.get_components_by_id<Transform>(sprite.game_object_id).front().get();
bool rendered_particles = this->render_particle(sprite, transform.scale);
diff --git a/src/crepe/system/RenderSystem.h b/src/crepe/system/RenderSystem.h
index 6643084..8841f72 100644
--- a/src/crepe/system/RenderSystem.h
+++ b/src/crepe/system/RenderSystem.h
@@ -25,13 +25,7 @@ public:
* This method is called to perform all rendering operations for the current game frame.
*/
void update() override;
-
-
- RenderSystem(const RenderSystem &) = delete;
- RenderSystem(RenderSystem &&) = delete;
- RenderSystem & operator=(const RenderSystem &) = delete;
- RenderSystem & operator=(RenderSystem &&) = delete;
-
+
private:
//! Clears the screen in preparation for rendering.
void clear_screen() const;
@@ -43,7 +37,7 @@ private:
void update_camera();
//! Renders the whole screen
- void render();
+ void render() const;
/**
* \brief Renders all the particles on the screen from a given sprite.
@@ -52,7 +46,7 @@ private:
* \param tm the Transform component for scale
* \return true if particles have been rendered
*/
- bool render_particle(const Sprite &, const double & scale);
+ bool render_particle(const Sprite & sprite, const double & scale) const;
/**
* \brief renders a sprite with a Transform component on the screen
@@ -60,7 +54,7 @@ private:
* \param sprite the sprite component that holds all the data
* \param tm the Transform component that holds the position,rotation and scale
*/
- void render_normal(const Sprite &, const Transform & tm);
+ void render_normal(const Sprite & sprite, const Transform & tm) const;
/**
* \todo Include color handling for sprites.