summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/game.cpp b/src/game.cpp
index e07a70bd..985b7ddc 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -767,9 +767,20 @@ void Game::handleInput()
player_node->setWalkingDir(direction);
+ // Target the nearest player if 'q' is pressed
+ if (keyboard.isKeyActive(keyboard.KEY_TARGET_PLAYER))
+ {
+ Being *target =
+ beingManager->findNearestLivingBeing(player_node, 20, Being::PLAYER);
+
+ if (target)
+ {
+ player_node->setTarget(target);
+ }
+ }
+
// Target the nearest monster if 'a' pressed
- if ( keyboard.isKeyActive(keyboard.KEY_TARGET_CLOSEST) )
- //if (keys[SDLK_a])
+ if (keyboard.isKeyActive(keyboard.KEY_TARGET_CLOSEST))
{
Being *target =
beingManager->findNearestLivingBeing(x, y, 20, Being::MONSTER);