Weird, I actually got your PMs.
Anyway, since I figured a few people might be interested in how the mouse gestures are done I am going to put the overview here…
I’ve learned during this project that mouse gestures are actually really easy to capture. Mostly, it just takes some tweaking to get it right. Start by determining the slope of each mouse movement the user makes.
m = (y1-y2)/(x1-x2)
Once I have my slope (m) I compare it to a list of predefined slopes that tell me which direction the mouse was moved. For instance, if the slope is greater than 2 I know the user dragged upwards.
I store each of the movements as integer values. I started with 0 moving clockwise around in a circle. I have 8 directions that I handle. Ie, 0 is up, 2 is right, 4 is down, 6 is left, and the odd numbers are all diagonals.
Once the user releases the mouse button, and I know their gesture is complete, I combine all of the directions they moved into a string. For instance, if the user dragged upwards you might have “00010007000001”. Obviously, most users will have slight variations in their gesturing, so my next step is to clean it up for them.
The first step in refinement is to delete the first and last characters of the string. I’ve noticed that a lot of users will drag at unintentional angles when they first click and when they let go. By deleting the first and last chars you remove that issue.
The second step of refinement is to remove random characters. For instance, in my example above I would remove the 1 and 7. I can do this by looking for characters that are not contiguous.
Finally, I condense the string into the smallest form possible by removing contiguous chars. In my example above this would result in the final string: “0”.
In order to see which gesture the user just performed I run their gesture through the levenshtein algorithm against all of the allowed gestures. This gives me a score for each of allowed gesture. Whichever one has the lowest score is the closest match to the user’s gesture.
Using our example from above, the user gestured “0”. In my game I define bounce as “0”, spin left as “6”, spin right as “2”, etc. The lowest levenshtein distance is to the bounce gesture, therefore I know the user just attempted to bounce.
I hope that all makes sense, but if you have some questions let me know.
Also, here is a link to an almost compiling levenshtein distance calculator.
http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_levenshtein/
Enjoy!