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 Discussion / detecting sequential keypresses for combo moves

Author
Message
phukol
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location:
Posted: 16th Mar 2004 00:10
high guys! juz wna ask if how i can i make DBC detect sequential keypresses so that i can execute certain moves. (e.g. like Hadoken - downkey, rightkey and punch button). I would greatly appreciate your ideas & samples

phukol
Douglass
21
Years of Service
User Offline
Joined: 28th Aug 2003
Location:
Posted: 16th Mar 2004 00:31
make a list to keep track of the keypress values and check for a certain order.

Tim Ballisto
21
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Right behind you.
Posted: 16th Mar 2004 00:43
i'm using the right shift as punch






phukol
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location:
Posted: 17th Mar 2004 00:23
thx guz. But Tim, if i used ur sample code, don't i need to press the keys all at once? Or will it be able to detect the keys one after the other just like executing hadoken. im gona try it out! thx

phukol
Code Ninja
21
Years of Service
User Offline
Joined: 17th Dec 2003
Location: AZ, U.S.
Posted: 17th Mar 2004 00:28
it looks like it should.

DragnBreth
of
Dragael Software
phukol
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location:
Posted: 18th Mar 2004 21:39
but what i want to implement is a sequential keypress( e.g. one after the other). Do you have other ideas besides this one. i already tried it out and it is not working the way i wanted to.

phukol
comando 300
21
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 18th Mar 2004 23:29
if keystate(208) then hadoken=1
if hadoken=1 and keystate(205)=1 then hadoken=2
if hadoken=2 and keystate(54)=1 then hadoken=3
if hadoken=3 then place hadoken commands here
if scancode()<>208 or scancode()<>205 or scancode<>54 then hadoken=0

I think that should work

CURRENT PROJECT: RETRO PAC-MAN
Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 18th Mar 2004 23:38
if keystate(208)
hadoken=1
time = timer()
endif
if hadoken=1 and keystate(205)=1 then hadoken=2
if hadoken=2 and keystate(54)=1 then hadoken=3
if hadoken=3 then place hadoken commands here
if scancode()<>208 or scancode()<>205 or scancode<>54 and ( timer() - time > 100 ) then hadoken=0

Dont know if this will work exactly like it is, but the basic thing about this code is that it gives you a second to perform the button combo after pressing the first required button.

Its not a bug, its a feature!
AtomR
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Portugal
Posted: 19th Mar 2004 13:26 Edited at: 19th Mar 2004 13:29
Off the top of my head, this is how i'd do it.

I would create an array
Keypresses(4,1)
This would store the last 5 (0 through 4) keys pressed and the times at which they had been pressed. Lets say that you want the combination 'qqa' done in less then 2 seconds (for arguments sake let's pretend the scancode of q=100 and the scancode of a=200) Then, unless I am mistaken, all you needed to do was ...

if Keypresses(2,0)=100 and keypresses(3,0)=100 and keypresses(4,0)=200 and keypresses(4,1)-keypresses(2,1)<2000 then
..... Do whatever you want.....
endif

what this does is check wether the last three keys pressed was qqa (in that order) and subtracts the time of the youngest key press from the oldest key press to check if it took less then 2 seconds (2000 miliseconds) for them to be pressed. You can do as many combinations as you like up to 5 keys but bear in mind that a combination of 'qqa' and a 'zqqa' would probably conflict with each other.

Hope this was helpfull.

Take care
AtomR
phukol
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location:
Posted: 20th Mar 2004 19:17
thnk you all guyz! ive gona try it out. Hope u can keep all ur theories and samples coming so that i can check them all out. TC

phukol

Login to post a reply

Server time is: 2025-05-31 17:45:17
Your offset time is: 2025-05-31 17:45:17