Frame-rate counter

Non-platform specific questions.

Frame-rate counter

Postby duracel92 » Sun May 28, 2006 10:09 pm

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 :?:
duracel92
 
Posts: 132
Joined: Sat Jan 21, 2006 10:45 pm
Location: UK
Score: 0 Give a positive score

Postby makslane » Sun May 28, 2006 11:02 pm

Use the real_fps variable:

textNumber = read_fps;
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby DilloDude » Sun May 28, 2006 11:50 pm

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.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby duracel92 » Mon May 29, 2006 12:26 pm

thank you both :)
duracel92
 
Posts: 132
Joined: Sat Jan 21, 2006 10:45 pm
Location: UK
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest