A better way to get the frame rate is to add it up over time then take the average. Averaging it over 10 to 20 frames is sufficient enough. For this, just create an array of ten objects, and do this:

Code:

var fps_logs[16]; // more means slower changes but less randomness

function get_framerate()
{
var main_array_index = 0;
var temp_array_index = 0;
var fps_average;

while(1)
{
fps_logs[main_array_index] = 16/time;
main_array_index += 1;
main_array_index %= 16; // always from 0 to 15, change if another array index is used
fps_average = 0;

while(temp_array_index < 16) // change 16 to your limit
{
fps_average += fps_logs[temp_array_index]; // adds up all this
}

fps_average /= 16;
fps_display = 16/(fps_average/16); // this can be just "fps_average" as is
temp_array_index = 0;
wait(1);
}
}



Then just let this code run. You may want to change the condition for the while loop, but this gives a decent idea. The code seems rather messy, but I don't know how else to simplify it, if possible.


"You level up the fastest and easiest if you do things at your own level and no higher or lower" - useful tip My 2D game - release on Jun 13th; My tutorials