(C#) A Good Frame Rate Counter

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
Joe_Oliveri
Posts: 448
Joined: Tue Oct 05, 2004 3:24 am
Location: Boston, MA

(C#) A Good Frame Rate Counter

Post by Joe_Oliveri »

Here is a good frame rate counter to use in your projects. I got this from a tutorial I was working with. Have fun!

Code: Select all

using System;
using System.Collections.Generic;
using System.Text;

namespace H4Game_Engine
{
    class FrameRateCounter
    {
        public static int CalculateFrameRate()
        {
            if (System.Environment.TickCount - lastTick >= 1000)
            {
                lastFrameRate = frameRate;

                frameRate = 0;

                lastTick = System.Environment.TickCount;
            }

            frameRate++;

            return lastFrameRate;
        }

        private static int lastTick;
        private static int lastFrameRate;
        private static int frameRate;
    }
}
Irrlicht Moderator || Game Designer
Learn the basics at </dream.in.code>
Post Reply