Use mathematical function to determine yaw direction

master
sfan5 2016-06-20 18:11:05 +02:00 committed by est31
parent 6014e7257e
commit 7a532056e2
1 changed files with 3 additions and 14 deletions

View File

@ -4298,23 +4298,12 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats,
inline static const char *yawToDirectionString(int yaw)
{
// NOTE: TODO: This can be done mathematically without the else/else-if
// cascade.
const char *player_direction;
static const char *direction[4] = {"North [+Z]", "West [-X]", "South [-Z]", "East [+X]"};
yaw = wrapDegrees_0_360(yaw);
yaw = (yaw + 45) % 360 / 90;
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;
return direction[yaw];
}