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 / Running Multiple Loops to Allow Consistent Frame Rate

Author
Message
Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 25th Nov 2010 02:06
Yep, another frame rate question So when i tried the cometsync function, it didnt work properly in either the dbc or dbp version. I researched other ways, and i kinda want all the code to be written by me, so i decided not to use it. the things i saw that could create a consistent fps were either adjusting the movement amount but that wouldn't allow for very good collision detection. the other method that would (collision detection is extremely important in my game) have 2 loops running at once: one for graphics, one for logic. but i was wondering if anybody had any good ways of explaining how to use that method. I really appreciate everybody's help!

also, thanks comet for trying to help me with your cometsync

New 3d marble game coming soon!
C0wbox
20
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 25th Nov 2010 02:15 Edited at: 25th Nov 2010 02:16
Sounds to me like you need time sharing >!!! - Or whatever it's actually called.

In the event that you really do need 2 loops running simultaneously, just combine them into 1 loop and have the processor switch between them per cycle with a boolean variable or something.



...or just combine them into 1 loop and stuff the time sharing because DBP can handle multiple things in 1 loop. (Processing the logic and collision at the same time in the DBP loop (which is already time-shared thanks to windows) will be a lot smoother than you manually switching the loop, as this will potentially halve the framerate unless you plan on syncing for each loop individually. )

Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 25th Nov 2010 02:22
Also, if anybody knows why adjusting move amount using dbp reported fps then please tell me, i cant really see why if collision detection would work at 60 fps and 1 angle of rotation per frame, it wouldnt work at 30 fps and 2 angles of rotation per frame for example...
im thinking it's becuase they relate everything to timers, when you could just look at the fps by using screenfps()

New 3d marble game coming soon!
Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 25th Nov 2010 02:24
haha thanks C0wbox!

New 3d marble game coming soon!
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 25th Nov 2010 03:39
sync rate 60 ???

Timer-based updates?


I don't see why collision would be affected? If it's affected on how quickly the game updates, maybe it needs to be rewritten. A swept-collision routine only requires the previous and current destination positions.

"Only the educated are free" ~Epictetus
"Imagination is more important than knowledge..." ~Einstein
Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 25th Nov 2010 04:53
thanks!

It's just what i heard somewhere, that it would get rid of collision detection... What im simply looking for is some relatively simple way to make the player or object or whatever move a consistent amount per time regardless of the fps. if you wanted the object to move 60 units per second, and the fps was 60, it would move one unit each frame. 1 fps=60 units per frame. in simple words, i want the game to monitor fps to make gameplay as consistent as possible, even if the framerate is very low. hope maybe that properly conveys what im asking xD


but thanks to all who have replied

New 3d marble game coming soon!
Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 25th Nov 2010 04:54
Another way to put it is it's one of those methods of getting things to be consistent across many different computers with many different performance levels.

New 3d marble game coming soon!
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 25th Nov 2010 16:42
Search for 'Decoupling The Display loop'

Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 25th Nov 2010 18:18
Hmmm... thanks. Ive decided that im not going to use multiple loops.

New 3d marble game coming soon!
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 25th Nov 2010 19:04
Could you possibly post what exactly didn't work with my function so I can improve on it? Thanks

TheComet

Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 25th Nov 2010 20:24
Well, i put it in, and it said "YOU HAVE HIT A FUNCTION DECLARATION MID-PROGRAM" and it would quit the program. i did some research on it and it said i needed to use the function which i strangely didnt do before, lol! So i did, and the error wouldnt come up, but the object would still freeze up sometimes...

New 3d marble game coming soon!
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 26th Nov 2010 10:46
Ah, a structure problem. Make sure you put it in exactly as described below:



TheComet

Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 26th Nov 2010 17:16
Thanks Comet, will try it sometime

New 3d marble game coming soon!
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 26th Nov 2010 18:12
The biggest thing you need is Timer Based Movement. The Decoupling of the Logic and Display loops really only comes into play when you need to increase performance.

..and when doing Timer Based Movement, don't rely on the TIMER() function. Use the HITIMER() function from IanM's Matrix1Utils. It's more accurate and reliable.

Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 26th Nov 2010 18:30
Thanks, i think ive got all of the stuff i need figured out. but i appreciate all of you help, kistech

New 3d marble game coming soon!

Login to post a reply

Server time is: 2026-07-21 12:51:06
Your offset time is: 2026-07-21 12:51:06