Gravity? Collision Platformer.

BlitzMax Forums/BlitzMax Beginners Area/Gravity? Collision Platformer.

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Here you go. This is Jump code at its simplest

' Jump Code for Kaisuo
' By AMon

SuperStrict

Graphics 800 , 600

Global Dude:TImage = LoadImage("dude.png")

Global Jump:Int = 0 ' Tracks whether we can jump
Global Gravity:Float = 0.3 'Gravity applied to jumpheight
Global JumpHeight:Float = 7 ' How High we can jump

Global dudeX:Float = 380 
Global dudeY:Float = 520

While Not KeyHit(KEY_ESCAPE)
	
	Cls
	
		DrawImage Dude, DudeX , dudey , 0
		DrawLine 0 , 570 , 800 , 570  
		
		If KeyHit(KEY_SPACE)
			Jump = 1
		End If
		
		DoJump()
		
		If dudeY >= 570 - 50 
			dudeY = 570-50
			Jump = 0
			JumpHeight = 7
		End If		
	Flip
	
Wend

Function DoJump()

	If Jump = 1 
		dudeY:-JumpHeight
		JumpHeight:-Gravity
		
		If JumpHeight <=-5 Then jumpHeight = -5
	End If
	
End Function


Replace the image with anything. :)