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 / Converting Frame Rate to Object Move Amount

Author
Message
Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 25th Nov 2010 18:30
Hello, fellow TGC dwellers. This is the third post ive made on the subject--nobody has properly understood my question. For now, forget about the frame rate stuff. All i want is a way to convert 60 fps for example to 1, and 1 to 60, 30 to2, 2 to 30, and so on. The obvious solution is to take 60 and divide it by the fps, but when the program starts, the fps is by default zero. so i use an if statement to convert that zero to 1, but the object is still rather erratic in its movements.

New 3d marble game coming soon!
Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 25th Nov 2010 18:38
haha now that i post something i find code that works, lol!
incase anybody else needs it, here yu go!


New 3d marble game coming soon!
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 25th Nov 2010 19:02 Edited at: 25th Nov 2010 19:03
You can of course also use my function:



Make sure c_syncrate is the same as the value you used for sync rate, and set c_update anywhere between 500 and 2000.

TheComet

RiiDii
21
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 25th Nov 2010 19:10 Edited at: 25th Nov 2010 19:12
In programming, there many ways to accomplish the same thing. This is one set of functions that I like to use for managing frame-rate based movement. It does not manage the frame-rate itself, which is another method often used to manage movement.

This set of functions is also probably over-complex for most small projects in that it allows for multiple simulated frame-rates at the same time. For example, it can support a player running at 60 FPS and slow bullets down to a crawl at 5 FPS for a bullet-time type simulation. It also uses the high resolution performance timer (PERFTIMER) for increased accuracy.

Like the code snippet you posted, this also includes a catch for the initial 0 frame as well as some other defensive code.



Since these functions do not manage frame rate and the calculations are always based on the previous frame, there is the possibility of a jump occurring. There is some defensive code included to cap a jump, but it could still be noticeable if the frame rate suddenly changes dramatically. I would therefore consider using a frame-rate management function along with these functions in order to make the game movement as smooth as possible.

*Edit: After posting this I read TheComet's post. That is an excellent example of frame rate management code.
Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 25th Nov 2010 19:41 Edited at: 25th Nov 2010 19:41
Nice example in both cases! I think ive found what ill do, and the marble game im making currently, (see signature) i want it to be all code i wrote my self, but thanks guys

New 3d marble game coming soon!

Login to post a reply

Server time is: 2026-07-21 12:49:05
Your offset time is: 2026-07-21 12:49:05