Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Handling sync rate.....

Author
Message
Inflictive
15
Years of Service
User Offline
Joined: 16th Jun 2009
Location: Altis
Posted: 9th Jun 2011 05:36
Hi, i've been working on my game, and i have come across an annoyingly confusing problem. Sync rate. From my knowledge, most comercial games these days start with v-sync off, but you can turn it on. I understand that a program running without v-sync is like using the command:

sync rate 0

and a program with v-sync on is like putting this in your main loop:

sync rate screen fps()

the thing is, i suppose it doesen't matter what the screen fps OR the main loop frequency is, but i want the actual game to have the same pace regardless of how crappy the user's computer is . For example, to handle just the physics, i might:

do

(commands)

rate#=60/screen fps()
updatephy#=updatephy#+rate#
variable#=updatephy#-prevupdates#

if variable#>=1
phy update
variable#=variable#-1
prevupdates#=prevupdates#+1
endif

if variable#>=1
phy update
variable#=variable#-1
prevupdates#=prevupdates#+1
endif

if variable#>=1
phy update
variable#=variable#-1
prevupdates#=prevupdates#+1
endif

loop

that way the physics would run at 60 hertz, regardless of the screen fps. is someone was getting 30fps, the physics would update twice each loop. if someone had 120fps, the physics should update every other loop. any wierd number, and the physics should still update at approxamitley 60Hz.

My question is, is that they way you would do it? How would you do it? Is it worth the trouble? If not, should I just limit my users to 60fps regardless of their computer, or perhaps have a "low performance" mode which limits users to 30fps and updates the physics and things twice per loop?

hmmmmm... KTHXBAI

*´¨;
¸.•´¸.•*´¨; ¸.•*¨;
(¸.•´ (¸.Eviljackson1
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 9th Jun 2011 17:43
You should search on the forums for "Timer Based Movement".

There is lots of discussion on here about it.

The example I learned from, and eventually adapted and improved upon was by Spooky and can be found >here<

Hope that helps.

KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 9th Jun 2011 18:07
Also have a look at Decoupling the Display Loop from the Game Loop to improve performance if your game is processor hungry. It will help keep fast computers under control, and help slow computers keep up. The article includes code for Timer Based Movement.

Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 10th Jun 2011 00:59
V-Sync can be controlled using the Set Display Mode command.

Set Display Mode Width, Height, Depth, VSyncOn, Multisampling Factor, Multimonitor Mode.

So if you place the command;

Set Display Mode 800, 600, 32, 1

at the start of your code, outside the main game loop, you should note that v-sync is on. Verify this by checking for screen tearing in your game.

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia

Login to post a reply

Server time is: 2024-11-22 22:17:12
Your offset time is: 2024-11-22 22:17:12