summary refs log tree commit diff stats
path: root/src/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp16
1 files changed, 9 insertions, 7 deletions
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 @@
5#include "components/droppable.h" 5#include "components/droppable.h"
6#include "components/ponderable.h" 6#include "components/ponderable.h"
7#include "components/orientable.h" 7#include "components/orientable.h"
8#include "systems/rendering.h"
9#include "systems/controlling.h" 8#include "systems/controlling.h"
10#include "systems/pondering.h" 9#include "systems/pondering.h"
11#include "systems/animating.h" 10#include "systems/animating.h"
12#include "animation.h" 11#include "animation.h"
12#include "renderer.h"
13#include "consts.h"
13 14
14void key_callback(GLFWwindow* window, int key, int, int action, int) 15void key_callback(GLFWwindow* window, int key, int, int action, int)
15{ 16{
@@ -22,14 +23,13 @@ void key_callback(GLFWwindow* window, int key, int, int action, int)
22 return; 23 return;
23 } 24 }
24 25
25 game.systemManager_.getSystem<ControllingSystem>().input(key, action); 26 game.systemManager_.input(key, action);
26} 27}
27 28
28Game::Game(GLFWwindow* window) : window_(window) 29Game::Game(GLFWwindow* window) : window_(window)
29{ 30{
30 systemManager_.emplaceSystem<ControllingSystem>(*this); 31 systemManager_.emplaceSystem<ControllingSystem>(*this);
31 systemManager_.emplaceSystem<PonderingSystem>(*this); 32 systemManager_.emplaceSystem<PonderingSystem>(*this);
32 systemManager_.emplaceSystem<RenderingSystem>(*this);
33 systemManager_.emplaceSystem<AnimatingSystem>(*this); 33 systemManager_.emplaceSystem<AnimatingSystem>(*this);
34 34
35 int player = entityManager_.emplaceEntity(); 35 int player = entityManager_.emplaceEntity();
@@ -64,6 +64,7 @@ void Game::execute()
64 double lastTime = glfwGetTime(); 64 double lastTime = glfwGetTime();
65 const double dt = 0.01; 65 const double dt = 0.01;
66 double accumulator = 0.0; 66 double accumulator = 0.0;
67 Texture texture(GAME_WIDTH, GAME_HEIGHT);
67 68
68 while (!(shouldQuit_ || glfwWindowShouldClose(window_))) 69 while (!(shouldQuit_ || glfwWindowShouldClose(window_)))
69 { 70 {
@@ -76,13 +77,14 @@ void Game::execute()
76 accumulator += frameTime; 77 accumulator += frameTime;
77 while (accumulator >= dt) 78 while (accumulator >= dt)
78 { 79 {
79 systemManager_.getSystem<ControllingSystem>().tick(dt); 80 systemManager_.tick(dt);
80 systemManager_.getSystem<PonderingSystem>().tick(dt);
81 systemManager_.getSystem<AnimatingSystem>().tick(dt);
82 81
83 accumulator -= dt; 82 accumulator -= dt;
84 } 83 }
85 84
86 systemManager_.getSystem<RenderingSystem>().tick(frameTime); 85 // Render
86 texture.fill(texture.entirety(), 0, 0, 0);
87 systemManager_.render(texture);
88 texture.renderScreen();
87 } 89 }
88} 90}