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 / what do you do to slow down your game?

Author
Message
bunghole
21
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Finland
Posted: 27th Oct 2004 04:12
if I put it like
"o = 1 to 4000: next o"
then it's speed changes between other computers.

I use DBC and have GeForce 4 64 Mt
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 27th Oct 2004 06:37
you need to keep track of the timer and alter the speed of all the game components when the game speeds up or slows down, for example if the game is meant to run at 40fps then thats 25msecs per frame, if the game slows down then you would be only manageing say 20 fps, if you check the timer difference each loop then you get50msecs per frame, so you need twice the speed of all the objects to keep up to the correct speed, if you divide the time it took for one frame by 25, then multiply your player/object speeds by this result(use a float), then when you run at 40 fps, the timer returns 25 and 25/25=1, speed*1=speed and your game runs at the correct speed, when you run on a slower pc and drop to 20 fps the timer returns 50, 50/25=2 (speed*2) so your game elements double their speed and appear to move at the same speed as the faster computer, sync rate 40 stops the code going too fast, and checking the timer speeds things up when required, you use a float so that variations like a couple of frames slowdown can be adjusted for, hope that explains things.

Mentor.

PC1: P4 3ghz, 1gig mem, 3x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
Xander
22
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 27th Oct 2004 08:45
That is quite a sentence there, Mentor

That is the exact method that I use, and I think every other professional program does that too. Here is a code example of how to do it (it should clear it up a little):



Xander Moser - Bolt Software - Firewall
bunghole
21
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Finland
Posted: 27th Oct 2004 18:02
(I ment "FOR o = 1 to 4000: NEXT o" btw)

Yeah, I'll have to try counting speed from FPS, when I go to my place. Now in school just checking forum..

I have both DB Classic and Pro and have GeForce 4 64 M
Indian Homie G
21
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 28th Oct 2004 16:23
or, just sync on, but then u cant get max FPS

AMD Athlon XP 3000+, S3 Deltachrome s8, 512 PC3200 RAM, 160 GB HD
bunghole
21
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Finland
Posted: 15th Nov 2004 17:15
dammit! this is little embarresing (did I write that wrong), but I still haven't get the program to go the same speed as on my computer as in my friends machine. I haven't got this problem before, because I didn't have to share my progs.
this sucks.

I have both DB Classic and Pro and have GeForce 4 64 M
Xander
22
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 15th Nov 2004 23:58
Use the code that I provide in the above post. It will do exactly what you want. If you have any questions about it, just ask.

Xander Moser - Bolt Software - Firewall

Login to post a reply

Server time is: 2025-05-26 00:19:13
Your offset time is: 2025-05-26 00:19:13