Main game loop measure = 10 ms

BlitzMax Forums/BlitzMax Beginners Area/Main game loop measure = 10 ms

hub(Posted 2006) [#1]
Hi !

for my 2d space game

i've measured my main game loop time. i've max 10 ms on my machine (time ellapsed between the cls, and just after the flip, all displayed at screen) FPS is fixed to 60. Is it good performance ?

Thanks !

My config : ATI Radeon 9200 series (128Mo), AMD2600+




Sledge(Posted 2006) [#2]
1000/60 is 16.67 - so yes, at 10ms your code is adequately fast.


Grey Alien(Posted 2006) [#3]
....for his machine. So I'd say it's too slow, imagine it on a 1GHz PC, it would run at half the frame rate.


JazzieB(Posted 2006) [#4]
I'd say the graphics card affects the speed a game runs more than the speed of the processor. That's a fairly average card he's got there so 10ms is probably about right. I'd say about 80-90% of the total time taken between Flips (including logic) is rendering.

To gauge true performance, hub, you need to include the time taken by the logic as well. Using my estimations, this should take the time up to no more than 12ms, which is still enough to maintain 60FPS.

I tested this game on my iBook, which has a 1.3Ghz processor and a Radeon Mobility 9550 with 32MB VRAM and it ran just fine. It goes without saying that it's also very smooth on my PC, but then I have a relatively high spec PC.


hub(Posted 2006) [#5]
thanks for your answers.
i report the time after the 'flip command. Don't know if it measure the 'flip'.

pseudo code :

While
cls <- start measure
compute all
< -- display previous time here.
Flip
<--- stop measure

Wend


Dreamora(Posted 2006) [#6]
stop the measure before flip unless you use flip 0 to disable the VSync.


JazzieB(Posted 2006) [#7]
As Dreamora says, you have to measure from when you start your main game loop to just before the Flip to determine how fast your game loop is, so that it includes both logic and render times. If you include the Flip you will always get the length of a single frame, i.e. 1/60th second if your game is syncing to 60 FPS (unless of course, you're not syncing with your monitor, or your loop is longer than one frame).


hub(Posted 2006) [#8]
i use flip 0. i don't know why but it works better with this.


hub(Posted 2006) [#9]
i use this code

	Graphics 1024,768,32, 75

	Const CTE_LIMITATION_FPS# = 60.0
	
	Local FPS_fps:Float = CTE_LIMITATION_FPS
	Local FPS_time:Float = 1000 / FPS_fps
	Local FPS_timer:Float = MilliSecs() + FPS_time	
	Local FPS_ms:Float
	
	Local Loop_Time : Float
	Local Computed_Loop_Time : Float	
	
	While (...)
	
	    FPS_ms = MilliSecs()
	    
		If (FPS_ms >= FPS_timer) Then

	    	FPS_timer = FPS_ms + FPS_time

			' code principal
			
			Cls
			
			Loop_Time = MilliSecs()			
			
			.... game code
			
			
			If bAfficherGC Then
				DrawText "GC=" + String(GCMemAlloced()), 0, GraphicsHeight() -30
				DrawText "Boucle=" + String (Computed_Loop_Time) + " ms",0, GraphicsHeight() -60
			End If			
									
			Flip 0
			
			Computed_Loop_Time = MilliSecs() - Loop_Time			
			
	    EndIf
								
	Wend			



hub(Posted 2006) [#10]
note that i've developped the game without know something about delta timing. So it seems difficult to add this to my game now... i've some difficulties exactly to know how to update my code !


ashmantle(Posted 2006) [#11]
Its not really that much of a rewrite. Just add Deltatime code into the loop and multiply everything that moves with your delta variable.

instead of : player.x = player.x + Speed
you write : player.x = player.x + (Speed * delta)

erm.. its been a long time since I've coded.. someone correct me :D


Dreamora(Posted 2006) [#12]
Good mainloop :-) You are one of the few that understood the need of timed screen refreshes to push the mainloop runs worlds higher and allow a real AI, smoother effects etc :-) (330 fps with always flip 0 to 500k-1500k with fixed 60 FPS through timed updating ;-) )