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.

DarkBASIC Discussion / the importance of sync on

Author
Message
ShadowCentaur 2
20
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Free Country USA
Posted: 15th Oct 2005 03:18
i recently forgot to put the "sync on" command at the beginning of my program (a primative space shooter). it worked fine but as complexity grew, my collisions became inconsistent. i searched the program for the problem, and after nearly giving up, finally found that this all important command was missing. i put it in, and now it works perfectly. a reminder: put sync on in first thing!

Truth suffers from too much analysis.
-Ancient Fremen Saying
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 15th Oct 2005 03:36
Ok. Not a useless thread, but I think everyone already does put on their sync for 3D games. Forgot to mention Sync Rate, pretty Important too...
blanky
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: ./
Posted: 16th Oct 2005 00:22
Xeno's right; It's now embedded into most DBC programmer's brains.
'Sync on' and either 'Sync Rate 0' or 'Sync Rate 75' (depending on whether it's frame-critical or not) is what I put at the top of all my programs...
As well as Set Display Mode, because 640x480 16-bit is disgusting.
Grossman
19
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Russia
Posted: 16th Oct 2005 03:14 Edited at: 16th Oct 2005 03:16
I can add that for the best performance you should create a syncroniser. For example:



The main ideas of syncroniser:
a) the main loop should run at constant rate;
b) the sync function should be called as often as possible;
c) if the system is weak, nesting of the loops (main and sync) should be reversed.

And don't use screen fps() function. Calculate FPS manually.
blanky
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: ./
Posted: 16th Oct 2005 14:11 Edited at: 16th Oct 2005 14:12
Quote: "inc loop_time"


Grossman, that wouldn't quite work; Effectively, you increase the loop_time that it's checking for by 1 with the inc command.

Quote: "if timer() = loop_time"


What if timer() had increased by 2 since the last time that bit of the loop was called?

It ought to be 'if timer() >= loop_time'...

...But it's not bad for a piece of timer-based code. ^^
Grossman
19
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Russia
Posted: 16th Oct 2005 19:09
Quote: "It ought to be 'if timer() >= loop_time'..."
Typo, sorry. Of course, it ought to be.

Quote: "Grossman, that wouldn't quite work; Effectively, you increase the loop_time that it's checking for by 1 with the inc command."
It can be like this:

But the main loop rate won't be constant.

So, here's another revision of my sync system:


Quote: "...But it's not bad for a piece of timer-based code. ^^"
It was written "on fly"...

Login to post a reply

Server time is: 2025-05-22 13:49:48
Your offset time is: 2025-05-22 13:49:48