Page 1 of 1

Frame-rate counter

PostPosted: Sun May 28, 2006 10:09 pm
by duracel92
I can't really explain this well, my english isn't very good even though I am english... :S

How do you, add a little text actor thing that displays the number that the frame rate is, like I think in DilloDudes "World War Whatever" game the little number that changes really frequently :?:

PostPosted: Sun May 28, 2006 11:02 pm
by makslane
Use the real_fps variable:

textNumber = read_fps;

PostPosted: Sun May 28, 2006 11:50 pm
by DilloDude
If you wanted, you could even add script to avarage it over, say, the previous second, so it wouldn't change so frequently. You would want an array of previous values and an integer to determine where you are up to.
So, if you want to check fifty frames, create a real array of size 50, called prevframes, and create an integer called frameno. Add a draw actor on your text number actor,
Code: Select all
prevframes[frameno] = real_fps;
frameno += 1;
if (frameno >= 50)
{
    int i;
    double addframe = 0;
    for (i = 0; i < 50; i ++)
    {
        addframe += prevframes[i];
    }
    textNumber = addframe / 50;
    frameno = 0;
}

I have not tested this, but it should work.

PostPosted: Mon May 29, 2006 12:26 pm
by duracel92
thank you both :)