HP Forums
Fps control - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Fps control (/thread-7289.html)



Fps control - SparklyUnicorn - 11-22-2016 07:19 PM

I was making space invaders, but I quickly realized that the frame rate dropped very quickly the more invaders that there were. Is there a way to create a stable framerate? I thing TEVAL() might work, but returns values in _s. I have been just using wait(.025).


RE: Fps control - eried - 11-22-2016 07:24 PM

(11-22-2016 07:19 PM)SparklyUnicorn Wrote:  I was making space invaders, but I quickly realized that the frame rate dropped very quickly the more invaders that there were. Is there a way to create a stable framerate? I thing TEVAL() might work, but returns values in _s. I have been just using wait(.025).

Can't you measure what is missing from the frame and adjust the wait?

example:
-get current ticks
-draw routine
-subtract current ticks from stored ticks, and wait what is needed to complete 30 fps, etc?


RE: Fps control - SparklyUnicorn - 11-22-2016 07:34 PM

(11-22-2016 07:24 PM)eried Wrote:  
(11-22-2016 07:19 PM)SparklyUnicorn Wrote:  I was making space invaders, but I quickly realized that the frame rate dropped very quickly the more invaders that there were. Is there a way to create a stable framerate? I thing TEVAL() might work, but returns values in _s. I have been just using wait(.025).

Can't you measure what is missing from the frame and adjust the wait?

example:
-get current ticks
-draw routine
-subtract current ticks from stored ticks, and wait what is needed to complete 30 fps, etc?
I didn't think of that, thanks!


RE: Fps control - Mark Power - 11-22-2016 09:12 PM

You might want to check out the excellent games articles at http://codeincomplete.com/games/. The technique eried describes is used and expanded in the examples.

JavaScript games aren't too tricky to port to the Prime - see Racer for inspiration. I partly implemented this technique, but found I just needed the Prime to run as fast as possible with all unnecessary code omitted.