10/17/2010 10:10:27 PM
Title:
How can I calculate mouse move speed?
Hi,
Can anybody tell us, how can I calculate mouse speed when I move the mouse.
http://www.dressupone.com/dressupgames/462/kissing-championship.html
Like this game... I want to do some animation as per the user mouse speed.
Thanks in advance,
Genieee
10/17/2010 10:37:33 PM
you can create a timer which will calculate the sped periodically say 100 milliseconds.
now on every timer event you need to store the initial x,y positions of the mouse and compare with the old saved x,y positions. Like this
newX=mouseX
newy=mouseY
//by substracting the new distance from old one you will get how many pixels were traveled in 100 milliseconds. And that's the speed
speed= (newX+newY)-(oldX-oldY);
oldX=mouseX
oldY=mouseY