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.

DarkBASIC Professional Discussion / multiple keys to be pressed at once

Author
Message
HellsDevilDog
15
Years of Service
User Offline
Joined: 18th Mar 2011
Location: Ohio
Posted: 26th May 2011 05:29
So I'm making a 2d game using sprites. I want many keys to be pressed at once. EG: W for walking, D for rotating, And R for reload all at the same time, But as of right now, Only 1 will be executed at a time. here's my code for the movements.



The above code is 1 of many sub routines I have implemented, just don't wanna paste all my code here

So yes, I'm sure this is an easy fix (I was just thinking of a fix using the "while" command, but I have no time to test this right now).

Any help is appreciated! Thanks!
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 26th May 2011 05:35
SCANCODE() was designed to learn the numbers of each key. It only shows the lowest numbered key that's hit. Use KEYSTATE() to actually detect keys so you can detect multiple keys. The only other use for SCANCODE() is to detect no keys being pressed (when you want the user to let go of all keys before moving on in code).



HellsDevilDog
15
Years of Service
User Offline
Joined: 18th Mar 2011
Location: Ohio
Posted: 26th May 2011 05:45
Ah, Thank!

I was attempting to use keystates, But I though they where different than scancodes. (I was using the numbers from the ASCII character codes image in the "Principles" help files for keystates)

Thanks again!
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 26th May 2011 06:23 Edited at: 26th May 2011 06:24
Oh, the ASCII Chart numbers are different. Here's my Keystate Map for quick reference (rather than using SCANCODE() every time you want to know the KEYSTATE numbers).



HellsDevilDog
15
Years of Service
User Offline
Joined: 18th Mar 2011
Location: Ohio
Posted: 26th May 2011 19:09
ha, That will really come in handy! Thanks again!

Login to post a reply

Server time is: 2026-07-10 18:03:07
Your offset time is: 2026-07-10 18:03:07