From 1400ade977e13e3b535d3c2fddb6e15de3c9b5a5 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 8 Feb 2018 13:43:10 -0500 Subject: Moved sprite rendering into AnimatingSystem Refactored how systems work slightly. Now, rendering can be done by a number of systems working together. Since the AnimatingSystem handles the animation of sprites, it should also handle the rendering of them. Because of this, the RenderingSystem has been removed. --- src/game.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/game.cpp') diff --git a/src/game.cpp b/src/game.cpp index 492e4d0..dfe700e 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -5,11 +5,12 @@ #include "components/droppable.h" #include "components/ponderable.h" #include "components/orientable.h" -#include "systems/rendering.h" #include "systems/controlling.h" #include "systems/pondering.h" #include "systems/animating.h" #include "animation.h" +#include "renderer.h" +#include "consts.h" void key_callback(GLFWwindow* window, int key, int, int action, int) { @@ -22,14 +23,13 @@ void key_callback(GLFWwindow* window, int key, int, int action, int) return; } - game.systemManager_.getSystem().input(key, action); + game.systemManager_.input(key, action); } Game::Game(GLFWwindow* window) : window_(window) { systemManager_.emplaceSystem(*this); systemManager_.emplaceSystem(*this); - systemManager_.emplaceSystem(*this); systemManager_.emplaceSystem(*this); int player = entityManager_.emplaceEntity(); @@ -64,6 +64,7 @@ void Game::execute() double lastTime = glfwGetTime(); const double dt = 0.01; double accumulator = 0.0; + Texture texture(GAME_WIDTH, GAME_HEIGHT); while (!(shouldQuit_ || glfwWindowShouldClose(window_))) { @@ -76,13 +77,14 @@ void Game::execute() accumulator += frameTime; while (accumulator >= dt) { - systemManager_.getSystem().tick(dt); - systemManager_.getSystem().tick(dt); - systemManager_.getSystem().tick(dt); + systemManager_.tick(dt); accumulator -= dt; } - systemManager_.getSystem().tick(frameTime); + // Render + texture.fill(texture.entirety(), 0, 0, 0); + systemManager_.render(texture); + texture.renderScreen(); } } -- cgit 1.4.1