summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
authorYaman <ybq987@gmail.com>2015-02-17 01:56:09 +1000
committerCraig Robbins <kde.psych@gmail.com>2015-02-17 01:56:21 +1000
commit98d80e2012ab4856b8b443ef498297e3d3eadbaa (patch)
treeed01ba23231d723572674786547ebc270976c903 /src/game.cpp
parentf1fd0f7e144acdd5da08554d996ba56c67ee7c46 (diff)
downloadminetest-98d80e2012ab4856b8b443ef498297e3d3eadbaa.tar.gz
minetest-98d80e2012ab4856b8b443ef498297e3d3eadbaa.tar.bz2
minetest-98d80e2012ab4856b8b443ef498297e3d3eadbaa.zip
Add player direction to on-screen debug text
(PR Modified slightly)
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 0645a7b80..7f0ac049c 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -3938,6 +3938,28 @@ void Game::updateFrame(std::vector<aabb3f> &highlight_boxes,
}
+inline static const char *yawToDirectionString(int yaw)
+{
+ // NOTE: TODO: This can be done mathematically without the else/else-if
+ // cascade.
+
+ const char *player_direction;
+
+ yaw = wrapDegrees_0_360(yaw);
+
+ if (yaw >= 45 && yaw < 135)
+ player_direction = "West [-X]";
+ else if (yaw >= 135 && yaw < 225)
+ player_direction = "South [-Z]";
+ else if (yaw >= 225 && yaw < 315)
+ player_direction = "East [+X]";
+ else
+ player_direction = "North [+Z]";
+
+ return player_direction;
+}
+
+
void Game::updateGui(float *statustext_time, const RunStats &stats,
const GameRunData& runData, f32 dtime, const VolatileRunFlags &flags,
const CameraOrientation &cam)
@@ -3993,6 +4015,7 @@ void Game::updateGui(float *statustext_time, const RunStats &stats,
<< ", " << (player_position.Y / BS)
<< ", " << (player_position.Z / BS)
<< ") (yaw=" << (wrapDegrees_0_360(cam.camera_yaw))
+ << " " << yawToDirectionString(cam.camera_yaw)
<< ") (seed = " << ((u64)client->getMapSeed())
<< ")";