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.

Newcomers DBPro Corner / Need help with inputs

Author
Message
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 12th Jul 2009 08:50
Hi all. I need some advice on getting player input. I want the player to be able to use both the keyboard and the mouse to move around the game map. If I trap with WAIT KEY, then I don't get the mouse clicks. If I trap with a loop that looks for key presses, I can get the mouse clicks, but unless the player makes a very quick key tap, I get multiple keypresses in the loop. I've tried using CLEAR ENTRY BUFFER, but it doesn't seem to do anything.

Is there a way to wait for a key press OR a mouse click at the same time?

Rich
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 12th Jul 2009 12:56
this code should just wait for a key press or a mouse click.



Altho I'm not quite sure if its what you want.

Without Music or Love the world would be a very empty place... Thank god I still have music.. --'-<@
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 12th Jul 2009 16:20
Thanks =PRoF=! That code does indeed trap both the keyboard and mouse. But...

I still get multiple keypresses and mouse clicks.

Like this:



My desire is to wait for input, process the key or mouse press, do other things, then go back to waiting for input. I need the functionality of WAIT KEY, but with mouse input trapped as well.

Any other ideas?
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 12th Jul 2009 19:19


Try this, I think its close to what u want.

Without Music or Love the world would be a very empty place... Thank god I still have music.. --'-<@
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 12th Jul 2009 19:50 Edited at: 12th Jul 2009 19:51
It's better to use the KEYSTATE() command to check for individual keys.

Each key has a KEYSTATE() number so checking for KEYSTATE(17) looks for W.



Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 13th Jul 2009 00:17
=PRoF=, that's exactly what I need!

Grog, I just converted it scan codes, too. Although they make it easier, since I don't have to check shifted or unshifted, etc., the scan code values are not intuitive at all. So I put them in constants, like...



and so on.

Thanks, both of you!

Rich

Login to post a reply

Server time is: 2024-11-25 04:55:52
Your offset time is: 2024-11-25 04:55:52