Is This Loop done Correctly?

BlitzMax Forums/BlitzMax Programming/Is This Loop done Correctly?

Hardcoal(Posted May) [#1]
I know ive asked almost a similar question.. but i forgot about that and made another post instead. so sry..

Im Getting to advanced stages of my project (The Stable Version, not the real End)
so now im starting to ask the question I delayed for all this time..


Field SavedMiliSec
Const WantedMiliSecs = 2

Repeat

	SavedMiliSec = MilliSecs()

	xCls()
	xRenderWorld()
	xUpdateWorld(5.0)
	
		'Do Something..

	xFlip()

	Delay(WantedMiliSecs - SavedMiliSec)

Forever



im trying to make the delay relative to the amount of time a loop consume..
am i doing it correctly.?

Ill be glad to hear anything about how a game loop should work
and what else should i know.

Thanks :)


Rooster(Posted May) [#2]
What do you mean by making the delay relative to the amount of time a loop consumes?
If what you want is a timer to control frame rate, then using WaitTimer () should work.

As far as your game loop go's it looks good.


Hardcoal(Posted May) [#3]
i want to pace to be consistent and i know nothing about waittimer command
ill check it out thanks.

so wait timer replaces delay?


Rooster(Posted May) [#4]
No it doesn't replace delay exactly, but it does sound like it's what your looking for.

I have been using it like this...

game_timer =CreateTimer (30)

'the Main loop
While endgame =0
 
 'code stuff...

 WaitTimer (game_timer)

Wend 


Hope this helps.


Hardcoal(Posted May) [#5]
ok tnx.. yea i does.. I guess


John G(Posted May) [#6]
Side question? Most displays were traditionally designed for a 60 Hz refresh.
If a new monitor claims 120 Hz or 144 Hz, should the game logic be adjusted if possible?