From eb40e3de7226d0005ce0a41c67c9355e675a489b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 25 Sep 2014 18:39:03 +0200 Subject: Add collision layer to maps and prevent movement into blocked areas --- src/control/MapContext.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/control/MapContext.cpp') 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 -- cgit v1.2.3