summaryrefslogtreecommitdiffstats
path: root/src/control
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-09-25 18:39:03 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-09-25 18:39:03 +0200
commiteb40e3de7226d0005ce0a41c67c9355e675a489b (patch)
tree2ca2b4c14fcfa8c94370dfe0d192f82e41943b92 /src/control
parentefa8640aabb3b4df31531ecd41ed1073dda63ed2 (diff)
downloadrpgedit-eb40e3de7226d0005ce0a41c67c9355e675a489b.tar
rpgedit-eb40e3de7226d0005ce0a41c67c9355e675a489b.zip
Add collision layer to maps and prevent movement into blocked areas
Diffstat (limited to 'src/control')
-rw-r--r--src/control/MapContext.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/control/MapContext.cpp b/src/control/MapContext.cpp
index 1904db4..acad969 100644
--- a/src/control/MapContext.cpp
+++ b/src/control/MapContext.cpp
@@ -37,7 +37,7 @@ MapContext::MapContext(EventBus *eventBus0, InputHandler *inputHandler0, const s
map.getEntities().emplace_back("square");
playerEntity = &map.getEntities().back();
- playerEntity->moveTo(Model::Position{8, 8});
+ playerEntity->moveTo(&map, Model::Position{8, 8});
view->updateEntities(map.getEntities());
@@ -50,14 +50,12 @@ MapContext::MapContext(EventBus *eventBus0, InputHandler *inputHandler0, const s
}
void MapContext::movePlayer(Model::Direction dir, uint64_t time) {
- if (playerEntity->hasTransition())
+ if (!playerEntity->move(&map, dir, time, time+250))
return;
- playerEntity->move(dir, time, time+250);
-
eventBus->enqueue(
[=] {
- playerEntity->finishTransition();
+ playerEntity->finishTransition(&map);
movePlayerContinue(time+250);
},
time+250