Game::Game()
: mWindow(sf::VideoMode(WindowWidth, WindowHeight), WindowName, sf::Style::Close)
, mPlayerTexture()
, mPlayer()
, mIsMovingDown(false)
, mIsMovingLeft(false)
, mIsMovingRight(false)
, mIsMovingUp(false)
{
if (!mPlayerTexture.loadFromFile("Media/Texture/eagle.png"))
{ }
mPlayer.setTexture(mPlayerTexture);
mPlayer.setScale(sf::Vector2f(0.25, 0.25));
mPlayer.setOrigin(sf::Vector2f(120.f, 135.f));
}
void Game::lookAtMouse(sf::RenderWindow &win)
{
sf::Vector2f curPos = mPlayer.getPosition();
sf::Vector2i position = sf::Mouse::getPosition(win);
const float PI = 3.14159265;
float dx = curPos.x - position.x;
float dy = curPos.y - position.y;
float rotation = (atan2(dy, dx)) * 180 / PI;
mPlayer.setRotation(rotation + 180);
}
the clooser it comes the more unaccurat it becomes.What does this mean?
Heres the relevant codeI really think you should read this (http://en.sfml-dev.org/forums/index.php?topic=5559.0).
Why do you test if loadFromFile() fails but then do nothing about it?if (!mPlayerTexture.loadFromFile("Media/Texture/eagle.png"))
{ }