1
Graphics / Re: Help with moving object according to rotation
« on: January 13, 2016, 04:53:12 pm »
It's hard to describe. In best words, it's point that it rotates around doesn't seem to be consistent. For example, when rotated 30 degrees, it moves in that direction as it should, but then when you change the rotation of the object to, say 60 degrees, it goes in a random direction that is not proportional to it's original direction.
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)){
object.rotate(0.5);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)){
object.rotate(-0.5);
}
X = speed*sin(object.getRotation());
Y = speed*cos(object.getRotation());
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)){
object.move(X, Y);
}
object.rotate(0.5);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)){
object.rotate(-0.5);
}
X = speed*sin(object.getRotation());
Y = speed*cos(object.getRotation());
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)){
object.move(X, Y);
}