Catch Me If You Can
Just for fun I am currently working on a small game. It's not a very interesting game. It’s a winform that displays a button and whenever the user hovers over the button it disappears to another location. The user has to try to push the button, before it moves to another location. The interesting part is that I used the OnMouseHover event to check whether the mouse is over the control or not. Unfortunaly this event was very slow. Each time the user was over the control it took approx. 2 secs before it moved away. That is very slow for such a game. After a research on the MSDN, I found that the mouse events occur in the following order.
- MouseEnter
- MouseMove
- MouseHover/ MouseDown/ MouseWheel
- MouseUp
- MouseLeave
I changed my code so that it works with the MouseEnter event and now it is much faster. :-)
Update1: Okay, I recognized that it was nearly impossible (after someone pointed it out to me) to catch the button, so I have added a new timer which waits 150ms before the button moves to another location. You have more than enough time to catch the button ;-). You can download the game here and the source code here. Let me know how you liked it. Remember I did this just for fun, so don't except too much.
Update2: Currently I am adding some new features (suggested by Brad), some graphics and some visualization effects so that it will look nice. After all its a game which should look nice ;)
Update3: I have added some features in the game. It will show you how many seconds/minutes you took to catch the button. If you are good and catch several times the button, then a second button will be added, which you also have to catch. If you are still good after the two buttons then a third button will be added and so on... Enjoy it! Keep it mind that I did this just for fun.
You can download the game here and the source code here.
Sonu