void Update()
{
D3DXVECTOR2 vec_aim = Engine::GetInstance()->GetInputModule()->GetMousePosition();
D3DXVECTOR2 vec_soldier = D3DXVECTOR2(GetPosition().x, GetPosition().y);
m_Angle = atan((vec_aim.y - vec_soldier.y) / (vec_aim.x - vec_soldier.x));
}
Aiming with the mouse
Hi!
I'm making a 2D shooter game. I want to aim with the mouse so, I'm using this formula :
But, there is a problem: it works only if the mouse abscissa coordinate are superior to the soldier abscissa coordinate. If not, the angle return to PI/2 or -PI/2
Click here to download the binaries
Thanks for all.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement