WaitTimer(60) quick question

Blitz3D Forums/Blitz3D Beginners Area/WaitTimer(60) quick question

Dax Trajero(Posted 2006) [#1]
The technique below produces lovely results when my monitor refresh rate is set to 60Hz (the same as the code below), but if I change the monitor to say 75Hz, things become really jerky. Is this because the code is out of SYNC with the user's monitor refresh rate ? Is there a way around this without using delta-time ?

frameTimer=CreateTimer(60)

While Not KeyHit(1)

WaitTimer(frameTimer)
update_game()
draw_game()

Wend


Dax Trajero(Posted 2006) [#2]
Like I said the above code doesn't produce smooth results unless the user's monitor is at 60Hz, so....

I suppose what I'm asking is if there's a technique to find out the user's refresh rate, create a timer based on this figure then only update the screen only 60 times each second ?

eg. user's monitor Hz = 100

frametimer=createTimer(100)
while not keyhit(1)
waitTimer(frametimer)

(code here to only draw screen 60 times per second instead of 100)

Wend



That way I get smooth updates as the timer is set to the user's refresh rate. However, as I'm only a beginner is it feasible to limit drawing to only 60 times a second, instead of whatever the monitors refresh rate is ?


b32(Posted 2006) [#3]
I think using "Flip false" can help, but the graphics will give interlacing problems.


chi(Posted 2006) [#4]
try this: http://www.blitzbasic.com/codearcs/codearcs.php?code=95

cheers, chi


Dax Trajero(Posted 2006) [#5]
thanks all

flip false never gives good results for me - its supposed to be the same as flip except the cpu waits for the vertical blank, doesn't it ? Always leaves my sprites jerking along


b32(Posted 2006) [#6]
Flip false doesn't wait for the vsync. It is good for testing purposes. You can see the actual speed of your program. I think you could also use tween rendering, I believe the castle demo of Blitz is using that.


Dax Trajero(Posted 2006) [#7]
b32, so whats tween rendering ?

Could that be perhaps running at a nominal framerate and only rendering x frames per second eg. if my game timing were based on 60Hz, and the user was running his screen at 80Hz, I'd only render 60 frames out of the 80 possible per sec ?


b32(Posted 2006) [#8]
It has something to do with the combination of CaptureWorld and RenderWorld. This is where I read about the castle demo: http://www.blitzbasic.com/b3ddocs/command.php?name=RenderWorld
Here is another thread about it:
http://www.blitzbasic.com/Community/posts.php?topic=37621


John Blackledge(Posted 2006) [#9]
And my own tutrial on tweening:
http://www.blitzbasic.co.nz/codearcs/codearcs.php?code=1497


IPete2(Posted 2006) [#10]
Hey John,

That's really good, I'm gonna go and takea moment to revise my klnowledge.

Thanks for that!

IPete2.


Naughty Alien(Posted 2006) [#11]
..here you can find all answers to your questions..

http://home.cmit.net/rwolbeck/programmingtutorial/