From 4720134d58cd5fe0846ed911b360ed75641cb874 Mon Sep 17 00:00:00 2001 From: Bertram Date: Thu, 22 Oct 2009 01:18:41 +0200 Subject: Fix flipping player's direction when using keyboard to walk diagonally. --- src/being.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/being.cpp') diff --git a/src/being.cpp b/src/being.cpp index d133225f..69e01dba 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -575,7 +575,13 @@ void Being::logic() // Update the player sprite direction int direction = 0; const float dx = std::abs(dir.x); - const float dy = std::abs(dir.y); + float dy = std::abs(dir.y); + + // When not using mouse for the player, we slightly prefer + // UP and DOWN position, especially when walking diagonally. + if (this == player_node && !player_node->isPathSetByMouse()) + dy = dy + 2; + if (dx > dy) direction |= (dir.x > 0) ? RIGHT : LEFT; else -- cgit v1.2.3-70-g09d2