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:
parent
bc9770e233
commit
be78434a9c
2 changed files with 5 additions and 5 deletions
|
@ -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;
|
||||
}
|
||||
|
|
2
Player.h
2
Player.h
|
@ -17,7 +17,7 @@ public:
|
|||
float fov = 70;
|
||||
|
||||
void move(float dx, float dy);
|
||||
void rotate(int alpha);
|
||||
void rotate(float alpha);
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue