diff options
author | Philipp Sehmisch <tmw@crushnet.org> | 2006-12-27 20:39:21 +0000 |
---|---|---|
committer | Philipp Sehmisch <tmw@crushnet.org> | 2006-12-27 20:39:21 +0000 |
commit | b2ef30efb59c8aa4df3bbaab376d46c583a40d98 (patch) | |
tree | bfa5f4b4dbb937b4413e79427bf1bbab8522dbdb /src/game.cpp | |
parent | 8da32105732949b4b0273c718d118bcfae70a1c9 (diff) | |
download | mana-b2ef30efb59c8aa4df3bbaab376d46c583a40d98.tar.gz mana-b2ef30efb59c8aa4df3bbaab376d46c583a40d98.tar.bz2 mana-b2ef30efb59c8aa4df3bbaab376d46c583a40d98.tar.xz mana-b2ef30efb59c8aa4df3bbaab376d46c583a40d98.zip |
Client-sided implementation of attacks
Diffstat (limited to 'src/game.cpp')
-rw-r--r-- | src/game.cpp | 43 |
1 files changed, 11 insertions, 32 deletions
diff --git a/src/game.cpp b/src/game.cpp index 15298ec6..21b6008e 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -509,6 +509,17 @@ void Game::handleInput() } break; + // attacking + // TODO: Reimplement attacking with joystick buttons + // (old code allowed permanent attacking and not 1 attack + // with each button push) + // I would like to do this but i don't own a joystick. + case SDLK_LCTRL: + case SDLK_RCTRL: + player_node->attack(); + used = true; + break; + // Quitting confirmation dialog case SDLK_ESCAPE: if (!exitConfirm) { @@ -651,38 +662,6 @@ void Game::handleInput() player_node->walk(direction); - // Attacking monsters - if (keys[SDLK_LCTRL] || keys[SDLK_RCTRL] || - joystick && joystick->buttonPressed(0)) - { - Being *target = NULL; - bool newTarget = keys[SDLK_LSHIFT] || keys[SDLK_RSHIFT]; - - // A set target has highest priority - if (newTarget || !player_node->getTarget()) - { - Uint16 targetX = x, targetY = y; - - if (player_node->getDirection() & Being::UP) - targetY--; - if (player_node->getDirection() & Being::DOWN) - targetY++; - if (player_node->getDirection() & Being::LEFT) - targetX--; - if (player_node->getDirection() & Being::RIGHT) - targetX++; - - // Attack priority is: Monster, Player, auto target - target = beingManager->findBeing( - targetX, targetY, Being::MONSTER); - if (!target) - target = beingManager->findBeing( - targetX, targetY, Being::PLAYER); - } - - player_node->attack(target, newTarget); - } - // Target the nearest monster if 'a' pressed if (keys[SDLK_a]) { |