Jump Routine

Blitz3D Forums/Blitz3D Programming/Jump Routine

Here's one with time... I tried to make it a little more realistic by adding real gravity force. I do not know the force of a jump going up, but I know that is at least more than gravity's force. This does not include mass... By my previous timing I could assume that it takes about 200 milliseconds until I get pulled completely down.... I need to take some physics classes...

Graphics3D 640, 480, 0, 2

cam = CreateCamera()

cube = CreateCube()
MoveEntity cube, 0, 1, 20
ScaleEntity cube, 1,1.9,1
cube2 = CreateCube()
MoveEntity cube2, 3, 0, 20

gravity# = 9.81
jumpforce# = gravity#+.2
jumptime = 200

Repeat

	If KeyHit(57) Then jump = True : im = MilliSecs()
	If jump = True Then
		tj = MilliSecs() - im
		If tj => jumptime Then jump = False
	EndIf
	
	If jump = True Then
		MoveEntity cube, 0, jumpforce#-gravity#, 0
	Else
		MoveEntity cube, 0, -gravity, 0
	EndIf
	
	
	If EntityY(cube) <1 Then PositionEntity cube, 0, 1, 20

	RenderWorld
	Text 0, 0, tj
	Text 0, 20, jump
	Text 0, 40, jumpforce#
	Flip
Until KeyHit(1)
End