Original Post
I have been through the mouse tutorial in Tom Miller's Managed DirectX9 book, however I cannot seem to expand on that to do anything useful. What I am trying to do at the moment is rotate a gun turret on a tank when the mouse is moved left or right. What I want to happen is for the turret to turn while the mouse is being moved and then stop when it isn't. However what is currently happening is that the turret turns when I move the mouse but then continues to spin once I have stopped using it. This is my current mouse input code: Any ideas where I'm going wrong? Thanks
private Device deviceMouse = null;
private MouseState stateMouse;
private long lMousePosCurrent, lMousePosOld;
stateMouse = deviceMouse.CurrentMouseState;
lMousePosCurrent = stateMouse.X;
if (lMousePosOld == 0)
{
lMousePosOld = lMousePosCurrent;
}
if (lMousePosCurrent != lMousePosOld)
{
clsObjects.TurnTurret(0, (int)(lMousePosCurrent - lMousePosOld), true);
lMousePosOld = lMousePosCurrent;
}
