diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-02-08 13:43:10 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-02-08 13:43:10 -0500 |
commit | 1400ade977e13e3b535d3c2fddb6e15de3c9b5a5 (patch) | |
tree | 3b44a7e9b60cff2423a7908404a4d6a5e79284f8 /src/game.cpp | |
parent | cefe66cdbb8786dc455657376e36f0ff8785d5bc (diff) | |
download | therapy-1400ade977e13e3b535d3c2fddb6e15de3c9b5a5.tar.gz therapy-1400ade977e13e3b535d3c2fddb6e15de3c9b5a5.tar.bz2 therapy-1400ade977e13e3b535d3c2fddb6e15de3c9b5a5.zip |
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.
Diffstat (limited to 'src/game.cpp')
-rw-r--r-- | src/game.cpp | 16 |
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 | ||
14 | void key_callback(GLFWwindow* window, int key, int, int action, int) | 15 | void 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 | ||
28 | Game::Game(GLFWwindow* window) : window_(window) | 29 | Game::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 | } |