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.

Geek Culture / Sort of a poll: How do you combat "Turbo Syndrome" in your programs?

Author
Message
Mr Underhill
21
Years of Service
User Offline
Joined: 23rd Apr 2003
Location: The Forgotten Worlds...
Posted: 24th Apr 2003 10:28
Y'Know sometimes when you run your program on your computer and it turns out fine, then you run the exact same proggy on your friend's faster, newer computer and it runs soooo fast it's not even playable?
Well, I thought that it'd be interesting if all you programmers out there listed how they defeated this programming demon.

BTW, I use a method I call "FPS Compensation", If you want to know what that means, just ask!
"not all that is gold does not glitter, not all those who wander are lost, not all that is old does not whither, deep roots are not reached by the frost..." - Aragorn (Strider)
bitJericho
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 24th Apr 2003 10:52 Edited at: 24th Apr 2003 10:53
ummm...i just don't play with the SYNC RATE command^_^ and make sure to turn sync on, and sync the proggy...

now if it's something other than db, then i would use the timer to update the screen so many times a second using this method:



The 3D Modeler's Group : http://groups.yahoo.com/group/3dModeler/
The Unofficial DB Newsgroup : http://groups.yahoo.com/group/DBMag/
Shadow
21
Years of Service
User Offline
Joined: 17th Oct 2002
Location: In the shadows
Posted: 24th Apr 2003 14:01
It's simple really. You can alter the program to take the sync rate into account so that it always looks the same speed, however fast it is.

For example:

`at the start of each loop get the sync rate:
fps#=screen fps()

`then, if you want something to increase by one each second:

inc varia#, 1/fps#

`and voila! it will always take one second regardless of sync rate
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 24th Apr 2003 15:02
Jerico you may wanna take a quick looksie at your timer
ya know what piss's me off about tha builtin DB timer() is that it doesn't start at 0

its annoying, had to build my own to get and accurate timing.

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
Kale
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: United Kingdom
Posted: 24th Apr 2003 15:16
Quote: "ya know what piss's me off about tha builtin DB timer() is that it doesn't start at 0"

surley it shouldn't? its system time from the epoch!

see here for a timing technique that may help:
http://www.garyw.uklinux.net/DB/optimisations.txt

What the flame does not consume, consumes the flame.
------------------------------------------------------------------------
AMD XP2100+, Geforce4Ti 4400, 512Mb DDR, Abit KX7, WinXP Home
Martyn Pittuck
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 24th Apr 2003 16:53
you know how to word wrap then

The Outside is a evil place to be, too much light, too much noise and too many distractions....
I went outside once and my FPS rate dropped to 5.
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 24th Apr 2003 17:02
well as the db timer always starts in the 3million mark ... and i've had not problem making a CPU based accurate time which starts from 0 when initiated. I means its just the OpenGL based timer from nVidia, which works perfectly for all my needs.

have you ever tried to use the timer values for calculation, its stupid - because it never returns accurate values ... whilst i was trying to setup accurate timers for the BSP engine for Rose's game, i came across so many instances of the bloody timer acting up and return values it shouldn't have been that i gave up and just used the FPS as a basis for a timer. Might be wrong but atleast i got values i could actually blasted well work with.

as the timer will count up from the second it is initated within DarkBasic/DarkBasic Pro i don't understand why they can't make it start at 0 ... really they should have 2
program timer()
timer()

one returns the overall time the programs been running, the other returns the time since it was last called... which is far easier for development as thats basically how mine work - only in DB Ehd they take some latency to call because they'rr in a DLL.

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
hexGEAR
21
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 24th Apr 2003 17:25
hmm, i just restrict my sync rate to 50 or 40, so no matter how fast the 3rd party computer is it's still sync restricted but theres the problem with slower computers

everyday of life is a new chapter that has already been fortold but is up to the soul to capture.
Mr Underhill
21
Years of Service
User Offline
Joined: 23rd Apr 2003
Location: The Forgotten Worlds...
Posted: 24th Apr 2003 20:54
shadow: Great minds think alike! That method you were talking about was what I called "FPS Compensation". Really effective, since faster machines only get a graphical boost. I love using it !

"not all that is gold does not glitter, not all those who wander are lost, not all that is old does not whither, deep roots are not reached by the frost..." - Aragorn (Strider)
bitJericho
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 25th Apr 2003 03:04
oh u guys are silly...
tim1# = TIMER()
`do some stuff to take up time
tim2# = TIMER()

tim2# - tim1# = how much time it took

The 3D Modeler's Group : http://groups.yahoo.com/group/3dModeler/
The Unofficial DB Newsgroup : http://groups.yahoo.com/group/DBMag/
Kale
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: United Kingdom
Posted: 25th Apr 2003 22:56
Quote: "
oh u guys are silly...
tim1# = TIMER()
`do some stuff to take up time
tim2# = TIMER()

tim2# - tim1# = how much time it took
"


yep! thats exactly how it should be done

What the flame does not consume, consumes the flame.
------------------------------------------------------------------------
AMD XP2100+, Geforce4Ti 4400, 512Mb DDR, Abit KX7, WinXP Home
W0LF
21
Years of Service
User Offline
Joined: 25th Apr 2003
Location: United States
Posted: 25th Apr 2003 23:16
I posted this the other day in the Real Game Tools Furum regarding this subject:

I have seen a lot of DB games and demos that use SYNC RATE as a way to limit their games speed. I used to use that method myself.

There are problems with doing it that way that I am sure most of you are aware of:
- The games run slower on slower machines
- People that have good computers are limited to the max refresh rate that you have set.
-It does not work correctly on all machines. I've had games run at 80fps with the sync rate set to 0. If I set the sync rate to 60 the game will run at something like 50fps instead of the 60 that I set. It only happens on some machines though.

Bottom line is this, people with different computer specs will have different experiences with your games.

I decided on my latest project, Out-Punch ("Mike Tyson's Punch Out" clone), to do the entire game based on the timer to eliminate the Sync Rate FPS problems. While converting to this method, I ran into some problems. The following is a description of how to implement this TIMER method and work around some of the difficult problems that you might face.

I at one time was working on a driving physics engine trying to use this method of refresh. One thing that kept giving me troubles was that while DB said it was running at a consistant frame rate, it was actually jumping around quite a bit. As I am sure you know, when using the timer refresh method instead of the sync rate method, any distance that an object moves has to be multiplied by the time interval. In the sync rate method, if you wanted your object to move, you would tell it to move so many units per loop. In the timer method, you have to figure out how far you want it to move in a certain time frame. For example if I wanted my Object to move 20 units in 1 second, I would have to do something like this:

Time# = TIMER()
DO : `Main Game Loop
elapsedTime# = TIMER() - Time# : `measure the amount of time that has elapsed since the previous loop
Time# = TIMER()

MoveDist# = 20*(elapsedTime#/1000) : `move 20 units per second
MOVE OBJECT 1,MoveDist#

SYNC
LOOP

For the most part, that works fine, and it is what most people use. I however was having problems with it because the elapsed time jumped around alot. In the driving physics code that I was working on that caused a lot of problems because if for some reason the previous refresh took extra long the car would go extra far to match making the game look very jumpy. To remedy this problem I decided to keep a running average of refresh times to use as my multiplier instead of just using the previous refresh time. I don't know if that is a standard practise for anyone else, because I have never seen it before, but it is working really well for me. Here is what I do:

IntLoops = 0 : ` A count of the loops that have occured
Integrator = 10 : `The number of "elapsed times" to keep a running average of
DIM ElTime#(Integrator) : `Array to store the elapsed times

Time# = TIMER()
DO : `Main Game Loop
GOSUB Time

MoveDist# = 20*(Ntime#/1000) : `move 20 units per second
MOVE OBJECT 1,MoveDist#

SYNC
LOOP

`----------------------------------------------------------------------------------------
Time:
`----------------------------------------------------------------------------------------
IF IntLoops <= Integrator THEN IntLoops = IntLoops + 1

FOR a = (Integrator - 1) TO 0 STEP -1
ElTime#(a+1) = ElTime#(a)
NEXT a
ElTime#(0) = TIMER() - Time#
Time# = TIMER()
NTime# = 0
FOR a = 0 TO Integrator
NTime# = NTime# + ElTime#(a)
NEXT a
NTime# = NTime# / IntLoops
IF NTime# = 0 THEN NTime# = 1
RETURN

This method is working very well for me. If you want to try it out, feel free. Using the timer method is definately the professional way to do things and will make a difference. It is a little more work, but it is definately worth the trouble.

If anyone is interested I also have my animation's speed working off of the timer method.

WOLF

HOOOWWWWLLLLL!!!!!!
bitJericho
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 26th Apr 2003 03:31
WOLF i didnt think of using an average time *slaps head*... cuz when I tried to implement the timer() it was jumpy as you said...

However...there is one little thing ya gotta watch out for...not sure if this is the same for the db timer() cuz i havent tested it.. but when the time hits midnite the timer() is reset to zero..which would cause havoc on the time# = tim2# - tim1#..

The 3D Modeler's Group : http://groups.yahoo.com/group/3dModeler/
The Unofficial DB Newsgroup : http://groups.yahoo.com/group/DBMag/
Mr Underhill
21
Years of Service
User Offline
Joined: 23rd Apr 2003
Location: The Forgotten Worlds...
Posted: 26th Apr 2003 09:06 Edited at: 26th Apr 2003 09:08
why not just use the frame rate to calculate movement amounts rather than limiting it (sync rate) or using that timer() stuff?
Just sounds simpler to me

"not all that is gold does not glitter, not all those who wander are lost, not all that is old does not whither, deep roots are not reached by the frost..." - Aragorn (Strider)
bitJericho
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 26th Apr 2003 09:09
some physics stuff would work better with using the timer... but otherwise i dont use it^_^

The 3D Modeler's Group : http://groups.yahoo.com/group/3dModeler/
The Unofficial DB Newsgroup : http://groups.yahoo.com/group/DBMag/
codeFusion
21
Years of Service
User Offline
Joined: 22nd Mar 2003
Location:
Posted: 26th Apr 2003 21:21
i also employ my own technology based upon FPS rates into games in order to guarantee a design target speed irrespective of machine spec..

where logic meets imagination, a fusion occurs; a harmony emerges
Shadow
21
Years of Service
User Offline
Joined: 17th Oct 2002
Location: In the shadows
Posted: 26th Apr 2003 21:34
:-s
I'm not sure what all this business with the timer is about, but I only make stuff for my own computer at the moment.

Login to post a reply

Server time is: 2024-05-09 18:43:23
Your offset time is: 2024-05-09 18:43:23