ok so I right click to get coords of mouse in window, then I'll set bGo to true and Go Vector to coords of mouse -half of the size of texture, so the middle of the texture will go to that point and set rotation
lets say I clicked on coords 100,200, and I'm on 200,400, therefore I'll go top left, so my rotation will be case 10 since it's left (2) and top ( 8 )
/*your code for window(RenderWindow) and player here - MainWindow & pPlayer*/
Vector2i Go;
bool bGo = false;
const float Speed = 75.f;
Clock clock;
int rot;
//message stuff
float ElapsedTime = clock.getElapsedTime().asSeconds();
clock.restart();
if(Mouse::isButtonPressed(Mouse::Right))
{
Go = Mouse::getPosition(MainWindow);
Vector2u size = pPlayer.getSize();
size.x /= 2;
size.y /= 2;
Go.x -= size.x;
Go.y -= size.y;
if(Go.x > Poss.x)
rot += 1;
if(Go.x < Poss.x)
rot += 2;
if(Go.y > Poss.y)
rot += 4;
if(Go.y < Poss.y)
rot += 8;
}
case 10:
{
if((Go.y - Poss.y) < Speed*ElapsedTime && (Go.x - Poss.x) < Speed*ElapsedTime)
pPlayer.Move(-Speed*ElapsedTime, -Speed*ElapsedTime, a);
else if((Go.x - Poss.x) < Speed*ElapsedTime)
{
pPlayer.Move(-Speed*ElapsedTime, 0, a);
if((Go.y - Poss.y) < Speed*ElapsedTime)
pPlayer.Move(0, -Speed*ElapsedTime, a);
}
else if((Go.y - Poss.y) < Speed*ElapsedTime)
{
pPlayer.Move(0, -Speed*ElapsedTime, a);
if((Go.x - Poss.x) < Speed*ElapsedTime)
pPlayer.Move(-Speed*ElapsedTime, 0, a);
}
else
{
bGo = false;
}
break;
}
BUT after he moves there he is like 98, 198, which is -2X and -2Y away from "destination", but this occurs only when I go more like 5pixels... and after I click again to 100,200 he will move there since he is close to it...