Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / How do I stop the mouse?

Author
Message
97 TJ
14
Years of Service
User Offline
Joined: 8th Dec 2009
Location:
Posted: 8th Dec 2009 19:38
First read this so you dont accidentally suggest something I've already done:

I'm making an air hockey game where the sidewalls and centerline are barriers to player one's mouse (so that you cant go out or into player 2's space... common sense).

I have the hockey stick set to the mouse's location, i have the actual mouse hidden and now im trying to stop it from going out.

I have tried all collisions possible:



Thats what im putting it in and I have tried:

dbWaitKey()
dbWaitMouse()
dbWait(1000)
dbSleep(1000)
etc.

it all make the mouse stop on the wall (thats great) but it requires a click or keystroke to make it move again.

How do i just make the mouse hit the wall and STOP like a barrier so i cant go outside that space?
heyufool1
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location: My quiet place
Posted: 8th Dec 2009 22:10
How about instead of making the mouse stop moving you just make the hockey stick stop moving, then do all mouse clicks and whatever based on the hockey stick's position?

The penguin faces south
Ultimate_H
15
Years of Service
User Offline
Joined: 11th Mar 2009
Location: A place that is neither here nor there
Posted: 8th Dec 2009 22:27
well, you could use the dbPositionMouse(X, Y) command, where you keep track of the previous mouse position in some variables. Then, if the mouse goes too far in either direction, you can reposition it in the old position. Something like this:



where MinX, MinY, MaxX and MaxY are the boundaries of your player box.

Hope that helps
-H

Check out my tutorial on how to make windows, and make them work with DarkGDK
97 TJ
14
Years of Service
User Offline
Joined: 8th Dec 2009
Location:
Posted: 8th Dec 2009 23:07
Hmm, seems to be an improvement. Seems like there would be an easier way though. Once the stick touches the wall it should just stop because its a wall (duh).

Login to post a reply

Server time is: 2024-11-20 09:38:27
Your offset time is: 2024-11-20 09:38:27