Skip to content

Commit 98d80e2

Browse files
yamanqZeno-
authored andcommittedFeb 16, 2015
Add player direction to on-screen debug text
(PR Modified slightly)
1 parent f1fd0f7 commit 98d80e2

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
 

‎src/game.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -3938,6 +3938,28 @@ void Game::updateFrame(std::vector<aabb3f> &highlight_boxes,
39383938
}
39393939

39403940

3941+
inline static const char *yawToDirectionString(int yaw)
3942+
{
3943+
// NOTE: TODO: This can be done mathematically without the else/else-if
3944+
// cascade.
3945+
3946+
const char *player_direction;
3947+
3948+
yaw = wrapDegrees_0_360(yaw);
3949+
3950+
if (yaw >= 45 && yaw < 135)
3951+
player_direction = "West [-X]";
3952+
else if (yaw >= 135 && yaw < 225)
3953+
player_direction = "South [-Z]";
3954+
else if (yaw >= 225 && yaw < 315)
3955+
player_direction = "East [+X]";
3956+
else
3957+
player_direction = "North [+Z]";
3958+
3959+
return player_direction;
3960+
}
3961+
3962+
39413963
void Game::updateGui(float *statustext_time, const RunStats &stats,
39423964
const GameRunData& runData, f32 dtime, const VolatileRunFlags &flags,
39433965
const CameraOrientation &cam)
@@ -3993,6 +4015,7 @@ void Game::updateGui(float *statustext_time, const RunStats &stats,
39934015
<< ", " << (player_position.Y / BS)
39944016
<< ", " << (player_position.Z / BS)
39954017
<< ") (yaw=" << (wrapDegrees_0_360(cam.camera_yaw))
4018+
<< " " << yawToDirectionString(cam.camera_yaw)
39964019
<< ") (seed = " << ((u64)client->getMapSeed())
39974020
<< ")";
39984021

0 commit comments

Comments
 (0)
Please sign in to comment.