diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-09-26 01:42:49 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-09-26 01:42:49 +0200 |
commit | d9f829f10a8310f53d945cd96ecce28193b792d8 (patch) | |
tree | b7b925e644c460632f1262df84cc84d36c096c9c /src/control/MapContext.cpp | |
parent | 3177ba222467e74d761d6a545ef05e8f1a0993c0 (diff) | |
download | rpgedit-d9f829f10a8310f53d945cd96ecce28193b792d8.tar rpgedit-d9f829f10a8310f53d945cd96ecce28193b792d8.zip |
Add support for interactions with entities
Diffstat (limited to 'src/control/MapContext.cpp')
-rw-r--r-- | src/control/MapContext.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/control/MapContext.cpp b/src/control/MapContext.cpp index f5d4c05..1b0e721 100644 --- a/src/control/MapContext.cpp +++ b/src/control/MapContext.cpp @@ -71,6 +71,15 @@ void MapContext::movePlayerContinue(uint64_t time) { movePlayer(Model::Direction::WEST, time); } +void MapContext::interact(uint64_t time) { + Model::Position<int> p = map.getEntityPosition(playerEntity) + playerEntity->getDirection(); + Model::Entity *target = map.getEntityAt(p); + + if (!target) + return; + + target->interact(time); +} void MapContext::keyPressed(uint16_t key, uint64_t time) { switch (key) { @@ -88,6 +97,10 @@ void MapContext::keyPressed(uint16_t key, uint64_t time) { case SDL_SCANCODE_LEFT: movePlayer(Model::Direction::WEST, time); + break; + + case SDL_SCANCODE_SPACE: + interact(time); } } |