1
0
Fork 0

Player: Fix rotate

Rotation wasn't handled properly at all.
Properly bound between 0 and 360, and use
a proper modulo for floats.

Switch to float to have a more fluid rotation
between frames.
This commit is contained in:
Teo-CD 2024-01-21 20:31:51 +00:00
parent bc9770e233
commit be78434a9c
2 changed files with 5 additions and 5 deletions

View file

@ -14,14 +14,14 @@ void Player::move(float dx, float dy)
y += dy;
}
void Player::rotate(int alpha)
void Player::rotate(float alpha)
{
orientation += alpha%360;
if(orientation >= 360)
orientation += fmodf(alpha, 360);
if(orientation > 360)
{
orientation -= 360;
}
if(orientation <= 360)
else if(orientation < 0)
{
orientation += 360;
}

View file

@ -17,7 +17,7 @@ public:
float fov = 70;
void move(float dx, float dy);
void rotate(int alpha);
void rotate(float alpha);
};