Framerate Independence

Jet

Flying in a sky near you
Veteran
Joined
Mar 19, 2012
Messages
172
Reaction score
103
First Language
English
Primarily Uses
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.
 
Last edited by a moderator:

BigEd781

undefined method 'stupid_title' found for nil:NilC
Veteran
Joined
Mar 1, 2012
Messages
940
Reaction score
304
First Language
Dothraki
Primarily Uses
N/A
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).
 

SolarGale

Learning
Veteran
Joined
Jun 8, 2012
Messages
479
Reaction score
37
First Language
English
Primarily Uses
Wow, this script sounds really useful for optimisation, might try it out later :3
 

BigEd781

undefined method 'stupid_title' found for nil:NilC
Veteran
Joined
Mar 1, 2012
Messages
940
Reaction score
304
First Language
Dothraki
Primarily Uses
N/A
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.
 

SolarGale

Learning
Veteran
Joined
Jun 8, 2012
Messages
479
Reaction score
37
First Language
English
Primarily Uses
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 :| )
 
Last edited by a moderator:

omoney

Ruby Nooby
Veteran
Joined
May 31, 2012
Messages
57
Reaction score
4
First Language
English
Primarily Uses
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.
 

Archeia

Level 99 Demi-fiend
Staff member
Developer
Joined
Mar 1, 2012
Messages
15,170
Reaction score
15,516
First Language
Filipino
Primarily Uses
RMMZ
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.
 

Jet

Flying in a sky near you
Veteran
Joined
Mar 19, 2012
Messages
172
Reaction score
103
First Language
English
Primarily Uses
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?
 

Archeia

Level 99 Demi-fiend
Staff member
Developer
Joined
Mar 1, 2012
Messages
15,170
Reaction score
15,516
First Language
Filipino
Primarily Uses
RMMZ
I wonder...I could try making a demo but it will take a while. I'll get back to you!
 

Maus Merryjest

Veteran
Veteran
Joined
May 8, 2012
Messages
240
Reaction score
40
First Language
English
Primarily Uses
Interestingly enough, this happened during a scrolling screen event:

 

Jet

Flying in a sky near you
Veteran
Joined
Mar 19, 2012
Messages
172
Reaction score
103
First Language
English
Primarily Uses
Interestingly enough, this happened during a scrolling screen event:

Should be fixed in the new version I put up, as well as another bug. Anyone using this should update.
 

Chaos17

Dreamer
Veteran
Joined
Mar 13, 2012
Messages
1,311
Reaction score
485
First Language
French
- delete this message, I made a noob mistake. -
 
Last edited by a moderator:

Latest Threads

Latest Posts

Latest Profile Posts

Stream will be live shortly! I will be beginning a play-through of Resident Evil 4! Feel free to drop by!

1st iteration on castle interior in Tiled.
I've started up Pillars of Eternity. It's interesting how the game does a "select choice" cutscene using still image art for dramatic flair. I wonder if that might work for my RPGMaker project.
The self-righteous indignation of family when you expect them to pay back money you've leant to them never ceases to amaze me.
Gamedev for relaxing? yes or no?

Forum statistics

Threads
107,735
Messages
1,031,745
Members
139,872
Latest member
ExSaNTIEr76
Top