summary refs log tree commit diff stats
path: root/src/game.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-02-11 12:34:52 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-02-11 12:34:52 -0500
commit77be863f4f15d2481a64e4e8dadb4060a6e4e590 (patch)
treeca571702d2148a75b5b847e77d26270257f54ebc /src/game.cpp
parent1400ade977e13e3b535d3c2fddb6e15de3c9b5a5 (diff)
downloadtherapy-77be863f4f15d2481a64e4e8dadb4060a6e4e590.tar.gz
therapy-77be863f4f15d2481a64e4e8dadb4060a6e4e590.tar.bz2
therapy-77be863f4f15d2481a64e4e8dadb4060a6e4e590.zip
Implemented map rendering and basic collision
Only wall and platform collision currently works, and map edges are not currently implemented.
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/game.cpp b/src/game.cpp index dfe700e..7cbe7e0 100644 --- a/src/game.cpp +++ b/src/game.cpp
@@ -8,6 +8,7 @@
8#include "systems/controlling.h" 8#include "systems/controlling.h"
9#include "systems/pondering.h" 9#include "systems/pondering.h"
10#include "systems/animating.h" 10#include "systems/animating.h"
11#include "systems/mapping.h"
11#include "animation.h" 12#include "animation.h"
12#include "renderer.h" 13#include "renderer.h"
13#include "consts.h" 14#include "consts.h"
@@ -26,10 +27,14 @@ void key_callback(GLFWwindow* window, int key, int, int action, int)
26 game.systemManager_.input(key, action); 27 game.systemManager_.input(key, action);
27} 28}
28 29
29Game::Game(GLFWwindow* window) : window_(window) 30Game::Game(
31 GLFWwindow* window) :
32 window_(window),
33 world_("res/maps.xml")
30{ 34{
31 systemManager_.emplaceSystem<ControllingSystem>(*this); 35 systemManager_.emplaceSystem<ControllingSystem>(*this);
32 systemManager_.emplaceSystem<PonderingSystem>(*this); 36 systemManager_.emplaceSystem<PonderingSystem>(*this);
37 systemManager_.emplaceSystem<MappingSystem>(*this);
33 systemManager_.emplaceSystem<AnimatingSystem>(*this); 38 systemManager_.emplaceSystem<AnimatingSystem>(*this);
34 39
35 int player = entityManager_.emplaceEntity(); 40 int player = entityManager_.emplaceEntity();
@@ -49,11 +54,16 @@ Game::Game(GLFWwindow* window) : window_(window)
49 player, 54 player,
50 203, 44, 10, 12); 55 203, 44, 10, 12);
51 56
57 systemManager_.getSystem<PonderingSystem>().initializeBody(
58 player,
59 PonderableComponent::Type::freefalling);
60
52 entityManager_.emplaceComponent<DroppableComponent>(player); 61 entityManager_.emplaceComponent<DroppableComponent>(player);
53 entityManager_.emplaceComponent<PonderableComponent>(player);
54 entityManager_.emplaceComponent<ControllableComponent>(player); 62 entityManager_.emplaceComponent<ControllableComponent>(player);
55 entityManager_.emplaceComponent<OrientableComponent>(player); 63 entityManager_.emplaceComponent<OrientableComponent>(player);
56 64
65 systemManager_.getSystem<MappingSystem>().loadMap(world_.getStartingMapId());
66
57 glfwSwapInterval(1); 67 glfwSwapInterval(1);
58 glfwSetWindowUserPointer(window_, this); 68 glfwSetWindowUserPointer(window_, this);
59 glfwSetKeyCallback(window_, key_callback); 69 glfwSetKeyCallback(window_, key_callback);