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.

  1. MouseEnter
  2. MouseMove
  3. MouseHover/ MouseDown/ MouseWheel
  4. MouseUp
  5. 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

Comments

# Ross said:


WHat happens if you hold down the button anyway on the screen and drag the cursor onto the button, is MouseEnter still fired?

Thursday, July 22, 2004 9:57 AM
# Sonu Kapoor said:

It will fired as soon you release the button. But you still wont be able to press the button, because it will move to an another location.

Thursday, July 22, 2004 10:19 AM
# Ross said:


I was just wondering about combinations of button presses and drags that might stop it firing. I know I've fooled a couple of Javascript right-click blockers like that in the past...

Thursday, July 22, 2004 11:04 AM
# Sonu Kapoor said:

I have uploaded the exe and the source code. You can try it out, if you like. Dont forget to tell me your thoughts ;)

Thursday, July 22, 2004 11:07 AM
# Ross said:


I haven't looked at the source but it's particularly hard to catch when part (most) of the button goes outside the bounds of the window.

Oh and if I resize it still puts the button somewhere in the original windows bounds.

I still haven't caught it :(

Thursday, July 22, 2004 11:18 AM
# Sonu Kapoor said:

I updated the exe, so that the window isn't resizeable and you will see in a messagebox how many times you catched the button. Enjoy it :-) I am thinking about some other features which can be added to improve the game.

Thursday, July 22, 2004 11:25 AM
# Sonu Kapoor said:

BTW: Souce code is also updated!

Thursday, July 22, 2004 11:26 AM
# dragonimp said:

it's easy to catch that :-)

move to the button and Mousedown without Mouseup and after the button moved to another location we move the mousepointer to the button(still mousedown at this momoment), the button is there still. OK, MouseUp now then you get it!

ahha:)))))))))))))

Monday, July 26, 2004 12:07 AM
# dragonimp said:

another bug:

using TAB to make the button get focus and then press Enter/blank to get it:)

you can set btn.TabStop=false to avoid.

Monday, July 26, 2004 12:50 AM
# Sonu Kapoor said:

Thanks dragonimp, I will make the changes you suggested!

Monday, July 26, 2004 12:57 AM
# Sonu Kapoor said:

DragonImp, I cant catch the button like you described with the mouse button down and mouse button up trick!

Tuesday, July 27, 2004 3:36 PM
# dragonimp said:

http://www.impx.net/download/other/catchme.exe

the video shows how i did

Wednesday, July 28, 2004 4:28 PM
# dragonimp said:

it's hard for us to click(move & down & up) in 150ms but it's easy to Mousedown at the sametime as mouseEnter(150ms is enough, in fact 20ms is enough:))
because if our mouse is down we move to the button MouseEnter would never fire!
So we just need to Enter and down in 150ms.

Wednesday, July 28, 2004 4:38 PM
# Sonu Kapoor said:

Intersting aspect dragonimp.

Wednesday, July 28, 2004 4:44 PM

Leave a Comment

(required) 
(required) 
(optional)
(required)