RMMV Is there a way to get how many frames have elapsed since launch?

EthanFox

Veteran
Veteran
Joined
Oct 15, 2018
Messages
609
Reaction score
396
First Language
English
Primarily Uses
RMMV
Is there a way to get how many frames have elapsed since launch?

Just asking because in my action game mode, I want to do some optimisation, and I have a few expensive operations which I want to do every other frame and every 4th frame, because they don't require 60-times-a-second accuracy and it'll improve performance for low-end users (more specifically; I'm looking at projectiles; I have an array of them, and I want to do certain checks on every odd projectile on odd frames and even projectile on even frames).

The checking bit is easy; it's just how I increment the loops in JS. However, is there an easy way to check how many frames have elapsed since boot?
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,158
Reaction score
10,731
First Language
Czech
Primarily Uses
RMMV
Thank God there isn't. Because if there was, with enough passed time the game would crash for out of memory. Although it'd take a loooot of time. :D

Plus it's completely irrelevant and inefficient. If you want to launch a function call every 2nd or 4th frame, you don't need to know how much time has elapsed.

Simply:
If x is 0, call both functions, increase x by 1.
If x is 1, increase x by 1.
If x is 2, call 2 frame function, increase x by 1.
If x is 3, set x to 0.

Much more efficient than tracking elapsed time and using division or modulo functions to see whether it's a 2nd frame, 4th frame or none.
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
34,329
Reaction score
8,755
First Language
German
Primarily Uses
RMMV
I think your best option for this is to add a frame counter yourself - just count a new variable up in one of your parallels that run every frame.

There are playtime counters, but it is always a question on what they are based on and how they react to lag if the regular gametime drops lower than the target of 60 frames per second.
 

EthanFox

Veteran
Veteran
Joined
Oct 15, 2018
Messages
609
Reaction score
396
First Language
English
Primarily Uses
RMMV
Thank God there isn't. Because if there was, with enough passed time the game would crash for out of memory.

Not for over millions of years of continuous running.

EDIT: I see you edited your post :D
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,158
Reaction score
10,731
First Language
Czech
Primarily Uses
RMMV
Yeah, I figured people wouldn't understand the joke. :D
 

Latest Threads

Latest Posts

Latest Profile Posts

Nightmare... Dreamt I posted a GFX resource post. With a work in progress glove icon that tinted to different colors. In the wrong forum. And I was in such a panic. I saw people writing posts in response, those "..." you see in discord and such. So I frantically tried to report my post as wrong forum, editing to say it's the wrong forum and that I "accidentally" posted it too early... Very odd dream to be honest...
The youngest photo of you is also the oldest photo of you.
People need to stop submitting their game to every single game jam without even reading the jam rules (╯°□°)╯︵ ┻━┻
Mom tested positive for COVID thanks to a single stupid coworker of hers not taking sh*t serious.
I'll prolly won't be on here for a while as we deal with this.
So before I inevitably start a new project to reorganize myself (I will make sure to save important info dw), I will make an external list of what I want in the final database.

Forum statistics

Threads
117,195
Messages
1,105,393
Members
153,334
Latest member
oGinToki
Top