Hey guys, im trying to make a game where you can controll a player around a object.
Key press A: Rotates counter clockwise.
Key press D: Rotates clockwise.
Key press W: Moves player away from centerobject, (opposite direction).
Key press S: Moves player towards centerobject.
Im having trouble getting the moment for W and S to work as i want it to...
For rotation i did :
globe.setOrigin(125.00f, 125.00f);
globe.setPosition(window.getSize().x /2.00f, window.getSize().y / 2.00f);
globe.setTexture(&globe_texture);
player.setOrigin(globe.getOrigin().x, globe.getOrigin().y); // Player get the same central as the globe.
player.setPosition(globe.getPosition().x, globe.getPosition().y);
For A and D:
if (Keyboard::isKeyPressed(Keyboard::Key::A))
{
counter = 0;
player.rotate(-0.5f); // Counter Clockwise.
}
if (Keyboard::isKeyPressed(Keyboard::Key:: D))
{
counter = 0;
player.rotate(0.5f); // Clockwise.
}
Thx!

