Computer Science Canada A type of frame rate control |
Author: | Kingnoz [ Fri Jul 23, 2004 12:57 pm ] | ||||||||
Post subject: | A type of frame rate control | ||||||||
This is a type of frame rate control that i am using now that works rather well for me. I'm using it for my RPG game. What this allows u to do is set the time u want things to delay for. It will figure out how much time passed during processing of graphics so ur program runs at the same speed everytime. Ok now for the code... The following variables should be placed at the top of ur program as global variables.
Variable Purposes changedelay - during testing this comes in handy because if u want to adjust the delay time to see how different speeds work then u can. (I'll show an example of this separately because it is not directly used in the main frame rate control code.) delay_defined - this is the overall time you want a designated set of instructions to delay for (the time elasped between the starttime and endtime variables...i'll explain further on this in the example) processtime - this is the amount of time that elapsed between the starttime and endtime delaytime - this is the variable placed in a Time.Delay, it is the balancing delay that makes things run the same. starttime - this is used at the start of wherever you want, i usually put it before multiple calculations and picture drawing processes are done. endtime - this is used at the end to finish the starttime. Now for an example of where to put everything... first thing to do is place the "starttime" variable - this is best placed before heavy processing like ur drawings.
this example was made to have the exact same delay everywhere... if u want delays to be different for different instruction sets then just put this line of code before the starttime instantiation.
and finally if you want to change your delay time in game for testing purposes then use this
I have tested this code, using a game of mine, with my brothers computer which is a pentium II 233 with 192 Mb RAM and worst graphics card ever and it worked pretty good. It was relatively the same as my computer, except for the fact that his computer is crap so the pictures don't look as good (but that is just a hardware thing) If you guys want i can post my rpg game that uses this method so you can see a practical example of my method at work...just pm me saying you want to see it and i will post it if there is enough interest to see it. |
Author: | Cervantes [ Fri Jul 23, 2004 4:22 pm ] |
Post subject: | |
nice simple and creative use of Time.Elapsed. +20 bits |
Author: | Kingnoz [ Fri Jul 23, 2004 5:23 pm ] |
Post subject: | |
thanks for the bits, greatly appreciated |
Author: | beard0 [ Wed Sep 01, 2004 8:32 am ] |
Post subject: | |
there is a much easier way of doing this: Turing Reference Manual wrote: Time.DelaySinceLast Part of Time module Syntax Time.DelaySinceLast ( duration : int ) Description The Time.DelaySinceLast procedure is used to cause the program to pause for a given time since the last call to Time.DelaySinceLast. The time duration is in milliseconds. |
Author: | Cervantes [ Wed Sep 01, 2004 8:42 am ] |
Post subject: | |
Isn't that feature new with Turing 4.0.5? And how does that incorporate the time it takes for the computer to process and draw all the stuff? |
Author: | beard0 [ Wed Sep 01, 2004 8:00 pm ] | ||
Post subject: | |||
Yes, that is new to turing 4.0.5 Cervantes wrote: And how does that incorporate the time it takes for the computer to process and draw all the stuff?
beard0 wrote: pause for a given time since the last call to Time.DelaySinceLast
You use it like:
|