Creating simple gravity - in BMax.

BlitzMax Forums/BlitzMax Beginners Area/Creating simple gravity - in BMax.

cool Ipete2

here is one with some X added:

Global  yvelocity:Float = 0
Global  grav:Float = 0.1
Global  ypos:Float =10
Global  xvelocity:Float = 1
Global  xpos:Float

Graphics 1024,768
Global GHEIGHT = GraphicsHeight()
Global GWIDTH = GraphicsWidth()
Global timer:TTimer = CreateTimer(90)
While Not KeyDown(key_ESCAPE)
 
 	yvelocity:+ grav
	ypos:+yvelocity

	If ypos>=GHEIGHT Then 
		ypos = GHEIGHT
		yvelocity=(-yvelocity)*0.95
	EndIf 
	
	If xpos<0 Then xdirection = 1
	If xpos>GWIDTH Then xdirection = 0
	
	If xdirection = 1
		xpos:+xvelocity
		Else
		xpos:-xvelocity
	EndIf
	
DrawOval xpos,ypos,20,20
WaitTimer(timer)
Flip 1
Cls
 
Wend
End