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 / How do you write clock speed code?

Author
Message
Wayne
23
Years of Service
User Offline
Joined: 3rd Jan 2003
Location:
Posted: 1st Jun 2003 22:28
I'm trying to write code to determine how fast the computer is so games can run at the average speed on all machines sync rate 0 doesn't work cause on mine I get 12-14 fps on my project, and it gets 62 on my buddies.

I havew a crap video card so that may be the reason, but if anyone knows how to write code to clock the processor, much obliged!

Wayne
AIPX Rocks
AsylumHunter
23
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: United States
Posted: 2nd Jun 2003 08:31
For CPU, not card tests, What I do is include a simple routine with some math tests and return the time it takes. Slower CPU's will obviously take longer to complete the routine so you can then adjust the your settings based off the results.

e.g.

StartTime = Timer()

for i = 1 to 10000000
a# = 1.1 *0.32123
b = 56 + 3453
c = 9987876/323
d #= 4323423.123/1236.54507
next i

EndTime = Timer()

TotalTime = EndTime - StartTime

AsylumHunter

still falling out of my binary tree most evenings (hicup!)
Andy Igoe
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 2nd Jun 2003 18:12
*look at above code and wonders if we're answering the same question*

Method 1

UP SIDE: Will force your friends computer to play the game at the same speed as your computer. Simple to code.
DOWN SIDE: Completely wastes the power of your friends computer and gives him the same jerky framerate despite the more powerful machine.

Method 2

PLUS SIDE: Maximises framerate across all computers and runs the game at the same speed regardless.
DOWN SIDE: Cannot apply percentages on a frame by frame basis, mommentum code therefor harder to write. Every movement in the game must be multiplied by the gameSpeed variable and therefor migrating your program may be a little effort. Exact values are hard to calculate, speeds are best attained by trial and error (gameSpeed=1000 over a second so would be 10 if you had 100fps, or 20 if you had 50fps).

You can also add together the framerate over the last half second and divide them to act as a dampening effect (a bit like suspension) which will help eliminate any jerkyness caused by background tasks eating processor time up.

Pneumatic Dryll
Wayne
23
Years of Service
User Offline
Joined: 3rd Jan 2003
Location:
Posted: 3rd Jun 2003 06:15
Maybe I'll just wait for my upgrade, then worry bout it

Thanx tho guys.

AIPX Rocks

Login to post a reply

Server time is: 2026-07-11 14:55:21
Your offset time is: 2026-07-11 14:55:21