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 / help me speed up my game, please

Author
Message
Indecom 4000
21
Years of Service
User Offline
Joined: 13th Apr 2004
Location:
Posted: 4th Jun 2004 19:03
hey, guys, I'm trying to find the equation for speeding up the game when the frame rate lowers. Do you guys know where this is or what this is? What I need is the game to run at the same speed no matter what the frame rate, like the game morrowind, when the rate drops instead of the main object moving a tiny bit at a slow speed it will take bigger gaps so it appears as the rate hasn't dropped. Any help would be appreciated!

Love to love me baby!
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 4th Jun 2004 19:27
You need to use the FPS as a multiplier. For example, pick a base frame rate of 50. If the frame rate drops to 40, multiply your movements by 50/40, or 1.25. If it increases to 60, it will be capped by your SYNC rate so you don't need to worry about it.

Alternatively, set the SYNC rate to 0, and always calculate the difference. This would actually be easier to code because it is conistent.

FPS() should be close enough to perform the calculation.

BatVink
http://facepaint.me.uk/catalog/default.php AMD 3000+ Barton, 512Mb Ram, 120 Gig Drive space, GeForce 5200 FX 128 Mb, Asus A7N8X Mobo.
Terms & Conditions apply
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 5th Jun 2004 04:36
hehe I was gonna ask that too...

for what I've understand...something like this?



:: Pentium 300 Mhz, 8Mb video card, 64Mb RAM, 5 gb & 1.6 gb HD's, W98SE, Sound Blaster AWE 32 ::

http://darkguy.redgaming.net
BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 5th Jun 2004 10:03
That is interesting, however, when I bump up the sync rate to say...60, and change the value in

NewYAng#=wrapvalue(YAng#+(0.5*(40/FPS)))

so it looks like

NewYAng#=wrapvalue(YAng#+(0.5*(60/FPS)))

The speed at which the cube rotates is slightly faster (5.61 secs at sync rate 40, 4.6 seconds at sync rate 60).

Then check this out:


Allow the computer to set its own sync rate, throw in some sprites to get the FPS down, and the ratio has changed.
30fps(with sprites) : 60fps(without sprites)
3.8 secs per rotation : 2.6 secs per rotation

But then we're only using 1 object and 7 sprites. Try something crazy like 27 sprites........

10fps(27 sprites) : 30fps(7 sprites) : 60fps(no sprites)
2.9 secs per rot : 3.8 secs per rot : 2.6 per rot

I hope I've found something useful.
The big thing to watch out for is to make sure when your program starts that it doesn't shrink down to 0 fps for a split second and then have DB generate a "Cannot Divide by 0" error, and if the FPS is greater than the preferred sync rate, then make sure FPS and speed always equal at least 1.

In the source button is a little way to test it with input on preferred sync rate and number of sprites to mess up the FPS. Test it then comment out "get image 1,0,0,80,80" and uncomment "load image "test.bmp",1" and try it out with a bitmap of your own for the sprite because I've found that get image is a little slow-just for testing.

BTW DarkGuy, my thanks to you for the example code. This one's been bothering me lately as well.

Crazy Donut Productions, Current Project: KillZone
Web Site Button Does Not Work, Visit Here: http://www.geocities.com/crazydonutproductions/index.html
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 5th Jun 2004 11:07
hehe no prob your code looks useful too, I'm gonna see what happens

BTW the code I did was done without DB, just by my mind I was 100% sure that will run, but I didn't imagine what could happen

:: Pentium 300 Mhz, 8Mb video card, 64Mb RAM, 5 gb & 1.6 gb HD's, W98SE, Sound Blaster AWE 32 ::

http://darkguy.redgaming.net

Login to post a reply

Server time is: 2025-05-23 22:23:11
Your offset time is: 2025-05-23 22:23:11