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 / Multiple SYNC

Author
Message
Kohaku
21
Years of Service
User Offline
Joined: 3rd May 2004
Location: The not very United Kingdom
Posted: 4th May 2004 05:25 Edited at: 1st Oct 2007 00:56
Does any one else use the sync command more than once in their main loop?

Editz0rz -

Hi all, after posting AGES ago back when I was quite new to teh codez0rz, I have learnt much.

One of those things is that using more than one sync is ok, as it's basically the same as having two separate loops that run after each other. It can however give a bit of a 'jerkiness' to the camera.

Anyway, long story short, to stay safe, stylish and professional, use one sync in conjunction with a delta system to ensure that your objects move at the correct speed regardless of the speed that the engine is running at.

These functions should see you safe:



You are not alone.
BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 4th May 2004 07:56
I only use it multiple times when I have a function that is called in the main loop and it kind of messes with the screen such as turning on/off the backdrop.

Crazy Donut Productions, Current Project: KillZone
Web Site Button Does Not Work, Visit Here: http://www.geocities.com/crazydonutproductions/index.html
zenassem
22
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 4th May 2004 08:27
Aura,

I recently posted a similar question in the "Newcomers Corner" thread titles "sync not always that simple". I also have had instances where I needed to use more than one Sync and/or two sync commands (one right after the other).

So far all I have been able to find out is.

1. I have seen it suggested that you can wind up with problems with sync if you call a subroutine that has a loop in it, from within you main loop. I find it hard to avoid this with my programming style.

2. Check out the last line in the description of the sync command in the help files. It may have something to do with the way DB makes use of a double buffer video refresh.

You are correct, that you should only have to call sync at the end of the main loop. I am trying to play with some examples so that I can show an example. It seems that not everyone is having this issue, by the lack of responses to the post. Perhaps it's a particular Video Card. I have everything else up-to-date (DirectX, Video Card Drivers, DBP 5.2, DBC ... etc)

Also, even in the "Dark Basic Book": The Chat program example uses multiple instances of double calls to sync.
...some code
sync
sync
...some code
sync
sync

I'm glad that I'm not the only on

BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 4th May 2004 14:15
Quote: "...if you call a subroutine that has a loop in it, from within you main loop"


This is not a problem, so long as you are managing the code. Yes, it would be a problem if circumstances such as:

1. Your subroutine loop is using too much timeslice, in this case your SYNC would always be slower than you anticipated. An example might be a loop that iterates 20,000 times, when the code dictates that 10,000 loops will eat all your available processing time.

2. Your subroutine is not synchronising with the rest of your code. An obvious example is moving a bullet in a loop in a subroutine. The bullet would move, and everything else would stop.

What I'm getting at is this: All subroutines should perform just one, streamlined step. It should not rely on local variables which are effectively wiped out each SYNC.

The need for multi-syncing is most likely due to bad coding.

To clarify, you can have many SYNCs in a program, but independant of one another. You could have a menu routine that is self-contained and uses one SYNC, and the main body of the game could be running from a second SYNC, but independantly of the menu.

Hope this helps.

BatVink
http://facepaint.me.uk/catalog/default.php AMD 3000+ Barton, 512Mb Ram, 120 Gig Drive space, GeForce 5200 FX 128 Mb, Asus A7N8X Mobo.
Terms & Conditions apply
Kohaku
21
Years of Service
User Offline
Joined: 3rd May 2004
Location: The not very United Kingdom
Posted: 4th May 2004 19:40 Edited at: 4th May 2004 19:41
Thanks everyone!

Login to post a reply

Server time is: 2025-05-23 17:33:46
Your offset time is: 2025-05-23 17:33:46