I am trying to do a small jumping test program. I think I got it down except for 1 thing.
(The blut squares are jumping pads and use left and right to move and space to jump)
The problem is when you try to go off the platform without jumping, you don't fall. I have tried to correct this but with no luck.
(The blut squares are jumping pads and use left and right to move and space to jump)
Graphics 800,600 Global man_x#,man_y#,jump#,man_speed#,j_speed#,j_num#,j_dir# SetBuffer BackBuffer() SeedRnd MilliSecs() man_x=395 man_y=400 j_speed#=3 jump=0 j_dir=-1 j_num=-0.06 man_speed#=3.0 tramp=0 level=400 While Not KeyHit(1) Color 255,0,255 Oval man_x,man_y,10,10,1 Color 0,255,0 Line 0,410,800,410 Color 255,0,0 Rect 100,340,300,10,1 Color 55,155,255 Rect 600,400,10,10,1 Rect 200,400,10,10,1 If KeyDown(203) :man_x=man_x-1*man_speed:EndIf If KeyDown(205) :run=1:man_x=man_x+1*man_speed:EndIf If man_speed>5 Then man_speed=5 If man_x<0 Then man_x=799 If man_x>799 Then man_x=0 If RectsOverlap(man_x,man_y,10,10,600,400,10,10) Then jump=1 If RectsOverlap(man_x,man_y,10,10,200,400,10,10) Then jump=1 If RectsOverlap(man_x,man_y,10,10,100,340,300,10) Then level=331 Else level=400 EndIf If KeyHit(57) Then jump=1 If jump=1 Then j_speed#=j_speed#+j_num man_y=man_y+j_dir*j_speed# If man_speed<0 Then j_dir=1 j_num=0.06 EndIf If man_y>level Then jump=0 man_y=level j_dir=-1 j_speed#=3 EndIf EndIf Text 10,10,j_speed Text 10,20,man_y Text 10,30,man_speed Flip Cls Wend
The problem is when you try to go off the platform without jumping, you don't fall. I have tried to correct this but with no luck.