summaryrefslogtreecommitdiffstats
path: root/src/control/MapContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/control/MapContext.cpp')
-rw-r--r--src/control/MapContext.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/control/MapContext.cpp b/src/control/MapContext.cpp
index 5c715db..e3f9a49 100644
--- a/src/control/MapContext.cpp
+++ b/src/control/MapContext.cpp
@@ -31,8 +31,19 @@ namespace RPGEdit {
namespace Control {
-MapContext::MapContext(EventBus *eventBus0, InputHandler *inputHandler0, const std::shared_ptr<const Model::Map> &map0)
- : eventBus(eventBus0), inputHandler(inputHandler0), map(map0) {
+MapContext::MapContext(EventBus *eventBus0, InputHandler *inputHandler0, View::MapView *view0, const std::shared_ptr<const Model::Map> &map0)
+ : eventBus(eventBus0), inputHandler(inputHandler0), view(view0), map(map0) {
+ for (const Model::Entity &entity : map->getEntities())
+ entities.emplace_back(new Model::Entity(entity));
+
+ playerEntity = new Model::Entity("square");
+ playerEntity->moveTo(Model::Position{8, 8});
+
+ entities.emplace_back(playerEntity);
+
+ view->updateEntities(entities);
+
+
inputHandler->registerListener(
[this] (uint16_t key, bool pressed, uint64_t time) {
if (pressed)
@@ -42,14 +53,14 @@ MapContext::MapContext(EventBus *eventBus0, InputHandler *inputHandler0, const s
}
void MapContext::movePlayer(Model::Direction dir, uint64_t time) {
- if (map->getPlayerEntity()->hasTransition())
+ if (playerEntity->hasTransition())
return;
- map->getPlayerEntity()->move(dir, time, time+250);
+ playerEntity->move(dir, time, time+250);
eventBus->enqueue(
[=] {
- map->getPlayerEntity()->finishTransition();
+ playerEntity->finishTransition();
movePlayerContinue(time+250);
},
time+250