Computer Science Canada Controlling loop cycle speed. |
Author: | TokenHerbz [ Thu Jan 06, 2011 6:01 am ] |
Post subject: | Controlling loop cycle speed. |
So in my tests my turing runs like, over 900,000 times in 1 minute. I want this to run only a measly 3600 times instead... Now i don't want to reply on "delays" to really do this, since that really effects the program differently to each persons computer. Optimally, I want a program to count to 60 within 1 second, for 60 seconds, for 3600 loops in a min. I'm not sure if i should try to set this up using Time.Elapse as the longer the program goes, well yeah, you know just doesn't seem all that logical to use. Any ideas? shoot em' out!... ///My idea was to have it check Time.Elapse, anyone else can think of a better way? |
Author: | Zren [ Thu Jan 06, 2011 7:35 am ] | ||
Post subject: | RE:Controlling loop cycle speed. | ||
This is two ways of controlling frames per second (FPS) that I know of. You can also look up the Time.DelaySinceLast(1000 / 60). The reason why I didn't use it for this example is because it hides information (but makes it simplier). Basically, this will slow down the program using a calculated delay when running too fast. The other is to move objects according to time for when it's running too slow. The problem with the latter is that you can sometimes bypass collisions if a computer was lagging really bad. So that method isn't exactly advised unless you deal with everything accordingly.
|