Hi everyone, I am having trouble getting boundaries to work in a simple game.
It's easy to do if my sprite only moves up, down, left, and right, because all I would have to do in that case is put in an if statement blocking the movement if sprite position was less or greater than the size of the window, etc.
What's making it hard for me to figure out is that my sprite rotates and can move in any direction.
if (App.GetInput().IsKeyDown(sf::Key::Up))
Ship.Move(-sin(Ship.GetRotation() * (3.14159265 / 180)) * ShipSpeed * App.GetFrameTime(), -cos(Ship.GetRotation() * (3.14159265 / 180)) * ShipSpeed * App.GetFrameTime());
if (App.GetInput().IsKeyDown(sf::Key::Down))
Ship.Move(sin(Ship.GetRotation() * (3.14159265 / 180)) * ShipSpeed * App.GetFrameTime(), cos(Ship.GetRotation() * (3.14159265 / 180)) * ShipSpeed * App.GetFrameTime());
if (App.GetInput().IsKeyDown(sf::Key::Left))
Ship.Rotate(300 * App.GetFrameTime());
if (App.GetInput().IsKeyDown(sf::Key::Right))
Ship.Rotate(-300 * App.GetFrameTime());
any hints? suggestions?