Can't get smooth sprite movement @ <50fps

BlitzMax Forums/BlitzMax Programming/Can't get smooth sprite movement @ <50fps

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.

[try this]

Strict

Local D3D7 = D3D7Max2DDriver()
Local OpenGL = GLMax2DDriver()
SetGraphicsDriver(OpenGL)

Graphics 800,600,32,60 '60hz

AutoMidHandle True

SetMaskColor(255,0,255)
Global blob:TImage = LoadImage("C:\Program Files\blitzmax\samples\simonh\fireworks\spark.png")

Global fps:fpsCounter = New fpsCounter
Global pause:Int = 0
Global bx:Int = 0
Global timer:Int = CreateTimer(40)

While Not KeyHit(KEY_ESCAPE)

	Local b:Int,i:Int
	
	'throw in a delay
	Delay pause
	
	'WaitTimer(timer)
	
	'an alternative to Delay
	'For i=1 To pause * 1000000
	'	b=i*i
	'Next
	
	If KeyHit(KEY_1) pause:-1
	If KeyHit(KEY_2) pause:+1
	If pause<0 pause=0 
	
	Cls
	DrawImage blob,bx,100

	bx:+10
	If bx>799 Then bx = 0
		
	fps.update()
	DrawText("use '1' and '2' to alter pause: "+pause,0,0)
	DrawText("FPS: "+fps.currentFPS,0,40)
		
	Flip
	FlushMem

Wend
End

Type fpsCounter
	Field currentFPS:Int
	Field oldMS:Int
	Field counter:Int
	
	Method Update()
		counter:+1
		If (MilliSecs() - oldMS) > 1000
			oldMS = MilliSecs()
			currentFPS = counter
			counter = 0
		End If
	End Method
End Type