# RMMVIs there a way to get how many frames have elapsed since launch?

#### EthanFox

##### Veteran
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
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.

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
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
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

#### Poryg

##### Dark Lord of the Castle of Javascreeps
Yeah, I figured people wouldn't understand the joke.

### Latest Profile Posts

Micro rant. The worst part of working from home when you live with your family is seeing how inconsiderate they are. "Hey, you're sitting in front of your computer, that means you're not doing anything! I want to put the TV at 200 decibels!"

If I was working in the office would you still talking me like that?
It's definitely discouraging when streamers give a try-to-say-it-nicely (i.e. bad) review of your game demo. It's like jumping into a cold pool. Bad initally, but it gets better with time. And you are now more alert and see better.
Some screenshots of the pub and lodging with the beginnings of clutter taking shape

Backgrounds are not my strong suit...

Just realized I forgot doing the clouds... woops