"Gimme teh codez" posts like this one are frowned upon on this forum. Coders are expected to put forth at least some effort to come up with a solution to whatever problem they are facing. Making video games is very enjoyable, but it takes effort and a willingness to learn.
That said, I did take the time to put together something basic for you this time.
`jumping based upon the time a key is held down
sync on : sync rate 60
autocam off
backdrop on : color backdrop 0
global player as integer : player = 2
global jumping as integer : jumping = 0
global JumpCtr as integer : global MasterCtr as integer
global JumpAmt# as float : JumpAmt# = 2.0
global JumpDelay# as float
global KeyTimer1# as float : global KeyTimer2# as float
global KeyStat as integer : KeyStat = 0
` make floor
make object box 1,1000,10,1000
position object 1,0.0,-10.0,0.0
color object 1,rgb(0,200,0)
` make character
make object cube player,10
color object player,rgb(0,0,200)
x# = object position x(player)
y# = object position y(player)
z# = object position z(player)
position camera x#,y# + 100.0,z# - 250.0
point camera x#,y#,z#
` main loop
repeat
if jumping > 0
if timer() > JumpDelay# then GoAheadAndJump()
else
if keystate(57) = 1 or KeyStat > 0 then CheckInput()
endif
sync
until returnkey() = 1
end
function CheckInput()
select KeyStat
case 0
` user has not pressed the SPACEBAR until now
KeyStat = 1
KeyTimer1# = timer()
endcase
case 1
` waiting for user to let go of the SPACEBAR
if keystate(57) = 0
KeyTimer2# = timer()
TotalTime# = (KeyTimer2# - KeyTimer1#)
` text 10,10,"TotalTime# = " + str$(TotalTime#)
` sync
` wait 1500
jumping = 1
JumpCtr = int(TotalTime# / 20)
if JumpCtr = 0 then JumpCtr = 1
MasterCtr = Jumpctr
endif
endcase
endselect
endfunction
function GoAheadAndJump()
if jumping = 1
move object up player,JumpAmt#
else
move object down player,JumpAmt#
endif
dec JumpCtr,1
if JumpCtr = 0
if jumping = 1
jumping = 2 : JumpCtr = MasterCtr
else
jumping = 0 : TotalTime# = 0.0 : KeyStat = 0
endif
endif
JumpDelay# = timer() + 10.0
endfunction
The 'player' jumps in proportion to how long the spacebar is held down. Exit by pressing the ENTER key.
Good luck to you,
LBFN
So many games to code......so little time.