Hey all thanks for taking the time to look at my problem, so I have a sprite that rotates perfectly towards the direction of the mouse but when i attempt to move it in that direction it only moves in the correct direction on the X axis. On the y axis if the mouse is above the sprite, it will move down or below it will make it move up...
so basically my question is - Why is my Y axis reversed!?
float Player::getRotation(sf::RenderWindow &win)
{
sf::Vector2f curPos; //current position(not cursor position, sorry for ambiguous var names!)
curPos.x = arrowSprite.getGlobalBounds().left;
curPos.y = arrowSprite.getGlobalBounds().top;
sf::Vector2i position = sf::Mouse::getPosition(win);
const float PI = 3.14159;
float dx = position.x - curPos.x;
float dy = position.y - curPos.y;
float rotation = (atan2(dy, dx)) * 180 / PI;
return rotation;
}
void Player::LookMouse(sf::RenderWindow &win)
{
float rotation = getRotation(win);
arrowSprite.setRotation(rotation);
}
void Player::Shoot(float deltaT,sf::RenderWindow &win)
{
arrowSprite.move( cos(getRotation(win)*3.14159265/180)*4, sin(getRotation(win)*3.14159265/180)*-4);
}
//lookMouse is called whenever the mouse moves, Shoot is called whenever spacebar is hit, getRotation is called as needed