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 Professional Discussion / Speed up your sync rate!

Author
Message
Kangaroo2
23
Years of Service
User Offline
Joined: 26th Sep 2002
Location: United Kingdom
Posted: 6th Dec 2002 11:54
Sorry, most people probably already noticed this but instead of using the 'sync' command to refresh your screen, in DBPro you can use 'fastsync' instead. Eg

sync on
sync rate 0
do
*insert program here, obv*
fastsync
loop

Just four letters added and already I get an extra 10 or so frames per second I know most people prefer to have a standard ammount of frames per second in a game (sync rate 60, for example), but maybe this little addition to a program will help others with lesser pcs than yourself achieve that? Also when programming applications or interface, such as a file explorer, media player etc, it could be very useful, improving smoothness.

Not sure if there are any dissadvantages to it, does it fluctuate for example? I've only just found it in the manual...
* If the apocalypse comes, email me *
Kale
23
Years of Service
User Offline
Joined: 8th Sep 2002
Location: United Kingdom
Posted: 6th Dec 2002 19:45
what is the difference anyway??? Lee?

What the flame does not consume, consumes the flame.
------------------------------------------------------------------------
AMD XP2100+, Geforce4Ti 4400, 512Mb DDR, Abit KX7, WinXP Home
MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 6th Dec 2002 20:29
According to the 'documentation', it seems to skip the windows messaging pump...

Good news everybody! I really am THAT good...
xtom
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Ireland
Posted: 6th Dec 2002 20:37
So what won't work properly when using it? I take it multiplayer doesn't.
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 7th Dec 2002 03:34
Sync will Update the entire functions and routine til that point, FastSync only updates the 3D aspect of things.

Anata aru kowagaru no watashi!
Kangaroo2
23
Years of Service
User Offline
Joined: 26th Sep 2002
Location: United Kingdom
Posted: 10th Dec 2002 16:39
In what way Raven?

I'm developing a program and while there are no function, the fast sync doesn't seem to ignore non-3d aspect, all the maths in my gosubs are updating.

I'm not saying you're wrong I'm justy trying to establish if its gonna miss anything important for my games

* If the apocalypse comes, email me *
Hilmi2k
23
Years of Service
User Offline
Joined: 29th Nov 2002
Location:
Posted: 10th Dec 2002 18:18
I was wondering about one very important thing if that will affect my games if I use sync rate 0 and fast sync.

My games are based on physics formulas. Time keeping important.... so for example, I might need to devide by 1/30 of a second in a game of sync rate 30.... how would I do that with sync 0?

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 10th Dec 2002 18:28
Use timer() instead.
Lampton Worm
23
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United Kingdom
Posted: 10th Dec 2002 18:45
If I have a time based game and I want to ensure time measurements are the same across different speed pc's, I assume I should be using timer(). For example, in a race game, if I record the time it takes you to do a lap, that time needs to be the same on a lower spec machine if the users does the exact same actions, running at a lower fps, that type of thing. Hmm. Another example, I wrote a beat system based on the timer, it keeps time on my PC, so in theory it'll keep time on a very slow spec machine still (its timer() based)..? Erm. So basically timer() runs at the same speed across all chipsets, so its cool to use in those ways. Just needed to reassume myself
Kangaroo2
23
Years of Service
User Offline
Joined: 26th Sep 2002
Location: United Kingdom
Posted: 10th Dec 2002 22:21
Yep timer is in theory the same on all pcs.

Obviously tho if you were doin a racing game, people with faster pcs would STILL have an unfair advantage over people with slower ones, as the higher frame rate would make the cars faster. With this type of game I stick to a steady 30 fps as this is probably realistic for the majority of gaming pcs

* If the apocalypse comes, email me *
waffle
23
Years of Service
User Offline
Joined: 9th Sep 2002
Location: Western USA
Posted: 10th Dec 2002 23:12
actually, fastsync should only effect other apps thereby blocking or reducing multitasking (thats the windows message loop) Game stuff should be OK except for things that require multitasking....

networking (directplay)
Using the CDRom
Some sound cards may be effected too.
Chroma
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: - Please Select -
Posted: 11th Dec 2002 09:14
For pro games you want to not lock the fps at a certain rate. You need to calculate the framerate delta time. That's the time it takes for 1 frame to flip. Then take all movements and multiply it by your delta time. That way all movements are the same across all computers and that player who chunked out that extra cash for the high end video card can get the silky smooth framerate that he deserves.

Pseudo code:

;// Timing And delta time
NewTime = Timer()
dt# = Float (NewTime - OldTime)/1000
OldTime = NewTime
fpsrate=1/dt

MoveObject blah,0,0, speed * dt

So if the speed is set to 1 then the object will move at 1 unit per second!!

The code above calculates the frame delta time and also the framerate all in one whack. You might have to modify it slightly for DBPro but give it a shot and you'll see how nice it is.
Lampton Worm
23
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United Kingdom
Posted: 11th Dec 2002 17:03
Thanks Chroma, I'll give that a go. Basically I want to be able to accuratly record timed events across different spec pc's. It has to be accurate, otherwise no point. Perhaps I'll set up some demo code to time a fixed event (e.g. move object from a to b), using your method above, then I can kindly ask people to run it and let me know their timings and their specs, the results *should* all be the same.

Cheers
Ratty Rat
23
Years of Service
User Offline
Joined: 24th Sep 2002
Location:
Posted: 11th Dec 2002 17:10
Chroma makes a good point here, the only way to ensure a constant speed in a game with a variable frame rate is to use the Timer() as he shows. Screen FPS() cannot be relied upon for this as its the Darkbasic engines FPS, not your game codes.

I used almost identical code in Breakout 3D (in DB1), once you`ve got that figure for a frame you can factor it into all the motion/physics/animation and keep everything at a constant rate.
Hilmi2k
23
Years of Service
User Offline
Joined: 29th Nov 2002
Location:
Posted: 11th Dec 2002 21:22
Thanx...

I am gainning so much from this forum, never learned this much in any forum before

Too bad my game is more a messy hairball of theory and only 3 A4 pages of code.

Kangaroo2
23
Years of Service
User Offline
Joined: 26th Sep 2002
Location: United Kingdom
Posted: 11th Dec 2002 23:21
Thanks Chroma that's really useful

* If the apocalypse comes, email me *

Login to post a reply

Server time is: 2026-06-11 16:07:06
Your offset time is: 2026-06-11 16:07:06