Heres my code guys. I can jump, But when i hit the platform i cant fall of it. To stay on the platform I have set the character Y pos to the same as the platforms.
I use a 2 pixel line on the platform and on the characters feet to test for collision.
I use a 2 pixel line on the platform and on the characters feet to test for collision.
Graphics 640,480 SetBuffer BackBuffer() ;>>>>>>>>globals<<<<<<<<<<<<<<<; Global dude = LoadImage ("dude.png") Global platform = LoadImage ("platform.png") Global dl = LoadImage ("dudeline.png") Global pl = LoadImage ("platline.png") Global px = 450 Global py = 375 Global dudeX# = 300 Global dudeY# = 390 Global canjump = 0 Global jump = 0 Global jumpheight# = 10 Global fall = 0 Global collide = 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;>>>>>>>>>constants<<<<<<<<<<<<; Const gravity# = .4 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; While Not KeyHit ( 1 ) Cls Locate 0,0 Print "Collide = " + collide DrawImage platform,px,py DrawImage pl,px,py DrawImage dl,dudeX# + 4,dudeY# + 84 DrawImage dude,dudeX#,dudeY# ;<<<<Function call >>>>; jump() ;------------------------------------ ;<<<<Function call>>>>>; ground() ;------------------------------------; ;<<<<Function Call>>>>>; movelr() ;------------------------------------; ;<<<<Function Call >>>>; collision() ;------------------------------------; Flip Wend End ;>>>>>>>>>>>>>>FUNCTIONS<<<<<<<<<<<<<<< Function jump() If KeyHit ( 57 ) canjump = 1 jump = 1 End If If canjump = 1 And jump = 1 Then dudeY# = dudeY# - jumpheight# jumpheight# = jumpheight# - gravity# Else jumpheight = 10 canjump = 0 jump = 0 End If End Function Function ground() If dudeY# > 390 Then canjump = 0 jump = 0 dudeY# = 390 End If End Function Function movelr() If KeyDown (203) dudeX# = dudeX# - 3 ElseIf KeyDown ( 205 ) dudeX# = dudeX + 3 End If End Function Function collision() If ImagesCollide (dl,dudeX# + 4,dudeY# + 84,0,pl,px,py,0) Then collide = 1 canjump = 1 jump = 0 dudeY# = dudeY# End If End Function