Post Reply 
Fps control
11-22-2016, 07:19 PM
Post: #1
Fps control
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).
Find all posts by this user
Quote this message in a reply
11-22-2016, 07:24 PM
Post: #2
RE: Fps control
(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?

My website: ried.cl
Visit this user's website Find all posts by this user
Quote this message in a reply
11-22-2016, 07:34 PM
Post: #3
RE: Fps control
(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!
Find all posts by this user
Quote this message in a reply
11-22-2016, 09:12 PM
Post: #4
RE: Fps control
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.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)