diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-08 20:21:36 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-08 20:21:36 +0100 |
commit | 506de66aaecc9b82415dde46058b848e46bc7258 (patch) | |
tree | a3f2427b0882d07f2d960b7214170533ad241830 /src/crepe/system | |
parent | 7817c85e84560933a33ad86ec3f9ca3d48d327d5 (diff) |
nitpicks (merge #27)
Diffstat (limited to 'src/crepe/system')
-rw-r--r-- | src/crepe/system/AnimatorSystem.cpp | 13 | ||||
-rw-r--r-- | src/crepe/system/AnimatorSystem.h | 22 | ||||
-rw-r--r-- | src/crepe/system/RenderSystem.cpp | 9 | ||||
-rw-r--r-- | src/crepe/system/RenderSystem.h | 80 |
4 files changed, 48 insertions, 76 deletions
diff --git a/src/crepe/system/AnimatorSystem.cpp b/src/crepe/system/AnimatorSystem.cpp index 4ea889a..bf45362 100644 --- a/src/crepe/system/AnimatorSystem.cpp +++ b/src/crepe/system/AnimatorSystem.cpp @@ -3,17 +3,16 @@ #include <functional> #include <vector> +#include "api/Animator.h" #include "facade/SDLContext.h" #include "util/log.h" -#include "api/Animator.h" -#include "ComponentManager.h" #include "AnimatorSystem.h" +#include "ComponentManager.h" using namespace crepe; AnimatorSystem::AnimatorSystem() { dbg_trace(); } - AnimatorSystem::~AnimatorSystem() { dbg_trace(); } AnimatorSystem & AnimatorSystem::get_instance() { @@ -22,12 +21,13 @@ AnimatorSystem & AnimatorSystem::get_instance() { } void AnimatorSystem::update() { - ComponentManager& mgr = ComponentManager::get_instance(); + ComponentManager & mgr = ComponentManager::get_instance(); - std::vector<std::reference_wrapper<Animator>> animations = mgr.get_components_by_type<Animator>(); + std::vector<std::reference_wrapper<Animator>> animations + = mgr.get_components_by_type<Animator>(); uint64_t tick = SDLContext::get_instance().get_ticks(); - for(Animator& a : animations){ + for (Animator & a : animations) { if (a.active) { a.curr_row = (tick / 100) % a.row; a.animator_rect.x = (a.curr_row * a.animator_rect.w) + a.curr_col; @@ -35,4 +35,3 @@ void AnimatorSystem::update() { } } } - diff --git a/src/crepe/system/AnimatorSystem.h b/src/crepe/system/AnimatorSystem.h index c377ce9..969e9d1 100644 --- a/src/crepe/system/AnimatorSystem.h +++ b/src/crepe/system/AnimatorSystem.h @@ -2,9 +2,7 @@ #include "System.h" - - -//TODO: +//TODO: // control if flip works with animation system namespace crepe { @@ -38,21 +36,9 @@ public: void update() override; private: - /** - * \brief Private constructor for the AnimatorSystem. - * - * The constructor is private to enforce the singleton pattern, ensuring that only - * one instance of this system can exist. - */ - AnimatorSystem(); - - /** - * \brief Private destructor for the AnimatorSystem. - * - * The destructor cleans up any resources used by the AnimatorSystem. It is private - * to maintain the singleton pattern and prevent direct deletion. - */ - ~AnimatorSystem(); + // private because singleton + AnimatorSystem(); // dbg_trace + ~AnimatorSystem(); // dbg_trace }; } // namespace crepe diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp index 849d810..10211a3 100644 --- a/src/crepe/system/RenderSystem.cpp +++ b/src/crepe/system/RenderSystem.cpp @@ -20,7 +20,9 @@ RenderSystem & RenderSystem::get_instance() { return instance; } -void RenderSystem::clear_screen() const { SDLContext::get_instance().clear_screen(); } +void RenderSystem::clear_screen() const { + SDLContext::get_instance().clear_screen(); +} void RenderSystem::present_screen() const { SDLContext::get_instance().present_screen(); @@ -45,8 +47,9 @@ void RenderSystem::render_sprites() const { SDLContext & render = SDLContext::get_instance(); for (const Sprite & sprite : sprites) { - auto transforms = mgr.get_components_by_id<Transform>(sprite.game_object_id); - render.draw(sprite, transforms[0] , *curr_cam); + auto transforms + = mgr.get_components_by_id<Transform>(sprite.game_object_id); + render.draw(sprite, transforms[0], *curr_cam); } } diff --git a/src/crepe/system/RenderSystem.h b/src/crepe/system/RenderSystem.h index ec80a0e..70db21a 100644 --- a/src/crepe/system/RenderSystem.h +++ b/src/crepe/system/RenderSystem.h @@ -4,7 +4,6 @@ #include "System.h" - namespace crepe { /** @@ -18,63 +17,48 @@ namespace crepe { class RenderSystem : public System { public: - /** - * \brief Gets the singleton instance of RenderSystem. - * \return Reference to the RenderSystem instance. - */ - static RenderSystem & get_instance(); + /** + * \brief Gets the singleton instance of RenderSystem. + * \return Reference to the RenderSystem instance. + */ + static RenderSystem & get_instance(); - /** - * \brief Updates the RenderSystem for the current frame. - * This method is called to perform all rendering operations for the current game frame. - */ - void update() override; + /** + * \brief Updates the RenderSystem for the current frame. + * This method is called to perform all rendering operations for the current game frame. + */ + void update() override; private: - /** - * \brief Constructs a RenderSystem instance. - * Private constructor to enforce singleton pattern. - */ - RenderSystem(); - - /** - * \brief Destroys the RenderSystem instance. - */ - ~RenderSystem(); + // Private constructor to enforce singleton pattern. + RenderSystem(); + ~RenderSystem(); - /** - * \brief Clears the screen in preparation for rendering. - */ - void clear_screen() const; + //! Clears the screen in preparation for rendering. + void clear_screen() const; - /** - * \brief Presents the rendered frame to the display. - */ - void present_screen() const; + //! Presents the rendered frame to the display. + void present_screen() const; - /** - * \brief Updates the active camera used for rendering. - */ - void update_camera(); + //! Updates the active camera used for rendering. + void update_camera(); - /** - * \brief Renders all active sprites to the screen. - */ - void render_sprites() const; + //! Renders all active sprites to the screen. + void render_sprites() const; - /** - * \todo Include color handling for sprites. - * \todo Implement particle emitter rendering with sprites. - * \todo Add text rendering using SDL_ttf for text components. - * \todo Implement a text component and a button component. - * \todo Ensure each sprite is checked for active status before rendering. - * \todo Sort all layers by order before rendering. - * \todo Consider adding text input functionality. - */ + /** + * \todo Include color handling for sprites. + * \todo Implement particle emitter rendering with sprites. + * \todo Add text rendering using SDL_ttf for text components. + * \todo Implement a text component and a button component. + * \todo Ensure each sprite is checked for active status before rendering. + * \todo Sort all layers by order before rendering. + * \todo Consider adding text input functionality. + */ private: //! Pointer to the current active camera for rendering - // \todo needs a better solution - Camera * curr_cam; + Camera * curr_cam = nullptr; + // TODO: needs a better solution }; } // namespace crepe |