what realize the combination keys? (consecutively)

Started by ATLUS, January 26, 2008, 10:36:53 AM

Previous topic - Next topic

ATLUS

I have already spent two hours and can not understand as in play be done combinations keys!To example us it is necessary that figure has flown with more quick velocity but for this us it is necessary to press twice a left!

reno

More games ? Go to my website :)
http://www.thereeteam.com/

ATLUS

Know in some play when you press two times onward beside you begin to run hero here is I too most want to learn to do

kevin


   I'm sorry, but I can't understand your question.  I think you want to get you're character to move.  If so, here's something to get you started.




setfps 50


; set the X# variable to the middle of the screen
x#=GetScreenWidth()/2
y#=GetScreenHeight()/2



Do
Cls rgb(0,200,100)


if LeftKey()=true then x#=x#-5
if RightKey()=true then x#=x#+5

; DRaw BOX for our human controlled character
Boxc X#-16,y#-100,x#+16,Y#,true,Rgb(200,20,30)



; Swap the back (invisible) buffer to be visible
Sync

; loop back to the DO to keep the program running
loop


ATLUS

#4
Sorry that has bad explained its problem!Yes and thanks for code but I this already knew.
Possible that us have an object which move under press;hit buttons at the speed of 1, but if we twice press on button that speed to become 4 if we wring out the button that speed again to become 1 and etc.
here is example not correct code:
x=300;object x exist
wk=timer();Get the current internal system time
speed=1;speed circle
do
cls rgb(0,0,0)
Print speed
if by>getscreenheight() then by=10
circle x,500,20,0
if rightkey()=1 then x=x+speed;move right
if leftkey()=1 then x=x-speed;move left
if leftkey()=0; if off buton then on timer
if timer()-wk<=2100; if timer<2.1 sec then speed=4
speed=4
wk=timer();return timer
else
speed=1;return speed
endif
if x<0 then x=0
if x>800 then x=800
sync
loop
endif



kevin


I think you're after something a bit more like this


SetFps 60


Dim KeyBoardStateBuffer(256)

type tKeyState
State
StartTime
HeldTime
Endtype

Dim Keys(256) as tKeyState


x#=GetSCreenWidth()/2



Do

; Call the Update KeyBoard function
UpdateKeyBoard()


Cls rgb(20,30,40)





; Check if the LEFT Arrow is being pressed
ThisKey=203
if ReadKey(ThisKey)

; Read how long this key has bheen pressed for
KeyDownTime=ReadDownTime(ThisKey)

; calc the Objects Movement speed base on how long the key had been pressed for
if KeyDownTime< 500
Speed#=1
elseif KeyDownTime<1000
Speed#=2
else
Speed#=4
endif

; Mopve the Objects
x#=x#-speed#
if x#<50 then x#=50
print Speed#
endif



; Check if the RIGHT Arrow is being pressed
ThisKey=205
if ReadKey(ThisKey)

; Read how long this key has bheen pressed for
KeyDownTime=ReadDownTime(ThisKey)

; calc the Objects Movement speed base on how long the key had been pressed for
if KeyDownTime< 500
Speed#=1
elseif KeyDownTime<1000
Speed#=2
else
Speed#=4
endif
; Move the Object
x#=x#+speed#
if x#>(GetSCreenWidth()-50) then x#=GetSCreenWidth()-50
print Speed#
Print KeyDownTime
endif



Circle X#,400,50,true

Sync
loop





Psub UpdateKeyBoard()

KeyBoardState KeyBoardStateBuffer()
CurrentTime=timer()
For ThisKey=0 to 255
State=KeyBoardStateBuffer(ThisKey)
Keys(Thiskey).state=State
if State=true

if Keys(Thiskey).StartTime =0
Keys(Thiskey).StartTime =CurrentTime
endif

Keys(Thiskey).HeldTime =CurrentTime-Keys(Thiskey).StartTime

else
Keys(Thiskey).state=State
Keys(Thiskey).StartTime =0
Keys(Thiskey).HeldTime=0
endif

Next
EndPsub


Psub ReadKey(ThisScanCode)
result=Keys(ThisScanCode).state
EndPsub result


Psub ReadDownTime(ThisScanCode)
result=Keys(ThisScanCode).HeldTime
EndPsub result


ATLUS

Big thanks!!!!!Now little comprehensible what build comba hits in game consecutively!But if take 3-4 different keys that as be? 

ATLUS


Adeythrash

I think he's on about how to do a tekken like control system, what with lots of button presses for the big combo's.

ATLUS

Quote from: Adeythrash on March 19, 2008, 04:27:57 AM
I think he's on about how to do a tekken like control system, what with lots of button presses for the big combo's.
yea 8-)