Hello, I was wondering, because I cannot figure out how to get this to work correctly, when I was using XNA the rotation it had was not in degrees but i believe went from 0 to 6 or something, and was a floatational value (I know, it's the dumbest thing I've ever heard). But now that SFML uses 360 float (much better), it appears that the method I had used previously, does not work. I don't know if I did something wrong with the XNA-SFML conversion, but it is completely irregular (i.e. I will turn a small amount and it will reverse (or random) to a direction).
This is the code I had used in XNA.....
/*if (Keyboard.GetState().IsKeyDown(Keys.W) |
Keyboard.GetState().IsKeyDown(Keys.S))
{
//Had to swap the cos, with the sin, and make the cos negative
//otherwise it would be walking the left side of the player,
//which just wouldn't make any sense.
PlayerVelocityAdditive.Y = -(float) Math.Cos(Player_CurrentRotation);
PlayerVelocityAdditive.X = (float) Math.Sin(Player_CurrentRotation);
PlayerVelocityAdditive *= Player_VelocityAccelerationMultiplier;
//modelVelocityAdd.X *= PlayerVelocityAccelerationMultiplier;
if (Keyboard.GetState().IsKeyDown(Keys.W))
{
Player_CurrentVelocity += PlayerVelocityAdditive;
}
else //else its S
{
Player_CurrentVelocity -= PlayerVelocityAdditive;
}
}*/
//...............
// Player_CurrentPosition += Player_CurrentVelocity;//add the current velocity, to the current pos.
And this is the code that I have converted to SFML....
sf::Vector2f Car_Velocity_Additive ;
Car_Velocity_Additive.y = -(float) cos (Sprite.GetRotation() )*3;
Car_Velocity_Additive.x = (float) sin(Sprite.GetRotation() )*3;
if (App.GetInput().IsKeyDown (sf::Key::W))
{
//Car_Velocity.y += 10;
Car_Velocity += Car_Velocity_Additive;
}
if (App.GetInput().IsKeyDown (sf::Key::S))
{
// Car_Velocity.y -= 10;
Car_Velocity -= Car_Velocity_Additive;
}
//Sprite.Move (0, -100 * ElapsedTime);
Sprite.Move (Car_Velocity.x *ElapsedTime, Car_Velocity.y*ElapsedTime);
Hopefully I didn't make a mistake in copy-paste. But anyways, I don't know why it's not working... I've tried swapping cos/sin, and using a negative in a diff place (or not at all(or both places)). Very confused I am(heh).
Anyways, hopefully you guys can help me, as this is really annoying, I do recall having the same problem with XNA, but it was because of me needing to swap the math functions or something to that degree.
I'm not entirely sure why we use these math functions, or how they do exactly (or should) what they do, however.