Framerate Independence

Framerate Independence

​



by Jet

​

Introduction

I've never quite understood why more games don't make themselves framerate independent. This meaning that say, a sprite is supposed to move 1 pixel every frame. You update at 60 FPS. The player, say due to a weak computer, only updates at 30 FPS. This independence from framerate would supplement by moving the sprite 2 pixels every frame instead of 1. This means that no matter what FPS the player is at, frame-based actions should take place in the same amount of time.

Features

- Frame-based actions are synchronized by time

- Plug and play

- That's basically it

Script

http://pastebin.com/raw.php?i=m4sGTgZ1

Credit

Jet

Note

This only applies this effect to the default engine. 3rd party scripts which use frame-based operations may still work at their regular speed instead of framerate independent.
As an aside, most engines do actually use a normalized update mechanism. Instead of depending on frames, they keep track of how many frames have passed in what amount of real time and then normalize according to that (which I assume is what you have done here).
Wow, this script sounds really useful for optimisation, might try it out later :3
I'm not sure how this could be used in an attempt to optimize anything. It simply accounts for the actual time difference between frames.
Oh ok, my bad xD

Edit: Though just for my sheer lack of knowledge, isn't it ensuring that the performance is closer to what it is actually intended? (Maybe my definition of optimisation in this context is wrong :| )
I think it just makes actions that are based on the number frames that passed occur more consistently across different machines that have different capabilities.
I tried this one out for testing because I have this map that would have a slow startup but backs up to 60 fps (because it was loading a huge picture animated parallax thing). What I noticed is that it never gets back upto 60 fps and forever stuck around 36 fps to 45 fps range. Unlike in the default where it jumps back to 60 fps after loading the picture. Was wondering if that's how it's supposed to work.
I tried this one out for testing because I have this map that would have a slow startup but backs up to 60 fps (because it was loading a huge picture animated parallax thing). What I noticed is that it never gets back upto 60 fps and forever stuck around 36 fps to 45 fps range. Unlike in the default where it jumps back to 60 fps after loading the picture. Was wondering if that's how it's supposed to work.
Definitely not supposed to happen, and it's very curious. I myself cannot replicate getting my fps "Stuck", it seems to waver around and rise back up as it sounds like yours should. Do you think there is any easy way for me to replicate the issue?
I wonder...I could try making a demo but it will take a while. I'll get back to you!
Interestingly enough, this happened during a scrolling screen event:

error-1.png
Interestingly enough, this happened during a scrolling screen event:

error-1.png
Should be fixed in the new version I put up, as well as another bug. Anyone using this should update.
- delete this message, I made a noob mistake. -

Original thread: https://forums.rpgmakerweb.com/threads/framerate-independence.2700/