|
-
June 29th, 2009, 09:18 AM
#7
Re: calculate mouse distance
I have the code now that perfectly tracks my cursor. But i'm still stuck with the boundarys of the screen. But i'll try to sketch a clear scenario.
I have a Timer which constantly checks the position of the cursor every 50 miliseconds. When i move the cursor the timer will see it:
Code:
//When the cursor is moved
if(lastPosX != CurrentPosX || lastPostY != CurrentPosY)
{
//calculate the distance
}
So every 50 miliseconds it gets my current mouse position, substracts that from my old cursor position which gives me the amount my cursor travelled in the X direction and Y direction.
When i move really slow along the X axis, i only see that i move 1 ~ 3 pixels every 50 miliseconds in my textfield.
This all is exactly what i want and it works perfectly now. But the problem is when i reach the end of the screen. If my screen width is 1024 x 768, and i'm at 1024. Then it can never calculate new movements because im at the end of the screen.
And that is something i don't want. Cause it's indeed to controll a camera in a game. I want to be able to move my mouse as far as i want.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|