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.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/control/MapContext.cpp b/src/control/MapContext.cpp
index 5fda337..f4dd31e 100644
--- a/src/control/MapContext.cpp
+++ b/src/control/MapContext.cpp
@@ -45,6 +45,36 @@ MapContext::MapContext(ImageLoader *imageLoader0, const std::shared_ptr<const Mo
entities[entity->getName()] = imageLoader->get("entity/" + entity->getName());
}
+void MapContext::advance(InputHandler *inputHandler, uint32_t ticks) {
+ uint64_t totalTicksOld = totalTicks;
+ totalTicks += ticks;
+
+ unsigned advance = totalTicks - totalTicksOld;
+
+ while (advance) {
+ advance = map->getPlayerEntity().advance(advance);
+
+ if (map->getPlayerEntity().hasTransition())
+ break;
+
+ if (inputHandler->isKeyPressed(SDL_SCANCODE_UP)) {
+ map->getPlayerEntity().move(Model::NORTH, 250);
+ }
+ else if (inputHandler->isKeyPressed(SDL_SCANCODE_RIGHT)) {
+ map->getPlayerEntity().move(Model::EAST, 250);
+ }
+ else if (inputHandler->isKeyPressed(SDL_SCANCODE_DOWN)) {
+ map->getPlayerEntity().move(Model::SOUTH, 250);
+ }
+ else if (inputHandler->isKeyPressed(SDL_SCANCODE_LEFT)) {
+ map->getPlayerEntity().move(Model::WEST, 250);
+ }
+ else {
+ break;
+ }
+ }
+}
+
}
}