summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-04-26 23:40:37 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-04-26 23:40:37 +0200
commit2d0e84449b14615bdacb6f897791628662bbfd39 (patch)
tree08019ae6c24c6da25e25da027d04ad008c25d6a2 /src/game.cpp
parent42605753159d7b63276351311e0fd43874a3366b (diff)
parent0056412ed33b941d72a175dcd3f025abcd8fc02b (diff)
downloadmana-2d0e84449b14615bdacb6f897791628662bbfd39.tar.gz
mana-2d0e84449b14615bdacb6f897791628662bbfd39.tar.bz2
mana-2d0e84449b14615bdacb6f897791628662bbfd39.tar.xz
mana-2d0e84449b14615bdacb6f897791628662bbfd39.zip
Made the client use a unique kind of movement code.
This is fixng many issues and (hopefully) will make the movement rendering much smoother. Merge branch 'master' of gitorious.org:~bertram/mana/mana-movement-code-merge Conflicts: src/being.cpp src/net/manaserv/beinghandler.cpp Resolves: TMW-Mantis #946. Reviewed-by: Thorbjorn.
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp61
1 files changed, 35 insertions, 26 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 8c8fb205..bcfd9ac2 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -390,6 +390,40 @@ void Game::logic()
}
/**
+ * handle item pick up case.
+ */
+static void handleItemPickUp()
+{
+ int x = player_node->getTileX();
+ int y = player_node->getTileY();
+
+ // Let's look for items around until you find one.
+ bool found = false;
+ for (int xX = x - 1; xX < x + 2; ++xX)
+ {
+ for (int yY = y - 1; yY < y + 2; ++yY)
+ {
+ FloorItem *item = actorSpriteManager->findItem(xX, yY);
+ if (item)
+ {
+ found = true;
+ player_node->pickUp(item);
+
+ // We found it, so set the player
+ // direction accordingly,
+ player_node->lookAt(
+ player_node->getMap()->getTileCenter(xX, yY));
+
+ // Get out of the loops
+ break;
+ }
+ }
+ if (found)
+ break;
+ }
+}
+
+/**
* The huge input handling method.
*/
void Game::handleInput()
@@ -621,32 +655,7 @@ void Game::handleInput()
{
case KeyboardConfig::KEY_PICKUP:
{
- int x = player_node->getTileX();
- int y = player_node->getTileY();
-
- FloorItem *item =
- actorSpriteManager->findItem(x, y);
-
- // If none below the player, try the tile in front
- // of the player
- if (!item)
- {
- // Temporary until tile-based picking is
- // removed.
- switch (player_node->getSpriteDirection())
- {
- case DIRECTION_UP : --y; break;
- case DIRECTION_DOWN : ++y; break;
- case DIRECTION_LEFT : --x; break;
- case DIRECTION_RIGHT: ++x; break;
- default: break;
- }
-
- item = actorSpriteManager->findItem(x, y);
- }
-
- if (item)
- player_node->pickUp(item);
+ handleItemPickUp();
used = true;
}