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 to make program operate at frame-rate independent speed?

Author
Message
Petrik
22
Years of Service
User Offline
Joined: 22nd Oct 2003
Location: Santa Monica, CA
Posted: 22nd Oct 2003 23:52
I'm pretty new to DBPro and programming in general. For practice, I wrote a little game prototype (a pong derivative) -- it runs fine, but the frame rate drops noticeably when the window is maximized. I know I could lock the display, but I'm curious to see if I can write it in a way where the game speed remains the same, even though the frame rate may be choppy. What are the best methods (in DBPro) to do this?
Mussi
23
Years of Service
User Offline
Joined: 27th Jan 2003
Location: Netherlands
Posted: 23rd Oct 2003 00:42
you mean, when you run in fullscreen exclusive mode the framerate drops to your monitor refreshrate?

Specs: AMD Athlon 1800, 256 DDRRam 266mhz, 80GB HD 7200rmp U133, Geforce 4 Ti4400 128mb ddr sdram
David T
Retired Moderator
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 23rd Oct 2003 00:43 Edited at: 23rd Oct 2003 00:43
Though you can never hide the effects of low frame rate (game gets choppy), you can scale any values you may use so it appears thep layer is moving at the same speed no matter what frame rate you get:





The speed to move the player at will be in the variable actualspeed#.

eg. If the game ran at 120fps, then the actual speed would be 5 (at it runs twice as fast as 60fps), but if it was 30fps then the speed would be 20, to catch up.

Fishie says:
"Those who fail to prepare prepare to fail"
"Rules are for the guidance of the wise and the blind obdeniency of the fools"
Petrik
22
Years of Service
User Offline
Joined: 22nd Oct 2003
Location: Santa Monica, CA
Posted: 23rd Oct 2003 08:44
thanks David89 -- makes sense. for now, i managed to do what i needed locking the sync rate at 60 (though i needed to increase the speed of the ball and paddle). one drawback -- the speed of the ball no longer feels visually constant, more like alternating between faster and slower speeds; it's especially obvoius at 60fps, which is the refresh rate of my laptop, so maybe it's related?

Login to post a reply

Server time is: 2026-07-26 05:21:27
Your offset time is: 2026-07-26 05:21:27