1
0
Fork 0
Toy-Raytracer/Player.cpp
Teo-CD be78434a9c 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.
2024-01-21 20:31:51 +00:00

28 lines
428 B
C++

//
// Created by trotfunky on 27/05/19.
//
#include "Player.h"
Player::Player(float x, float y, float alpha) : x(x), y(y), orientation(alpha)
{}
void Player::move(float dx, float dy)
{
x += dx;
y += dy;
}
void Player::rotate(float alpha)
{
orientation += fmodf(alpha, 360);
if(orientation > 360)
{
orientation -= 360;
}
else if(orientation < 0)
{
orientation += 360;
}
}