NOOB: Limit to 'x' frames per second for every machine

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
robpearmain
Posts: 12
Joined: Mon May 22, 2006 2:56 pm

NOOB: Limit to 'x' frames per second for every machine

Post by robpearmain »

Sorry about this, but what if I want it to run at 'x' frames per second on low and and high end pc's.

Is this built in to Irrlicht or do I have to build it myself.

For example, if I am moving a vehicle 60 feet per second, I want to make sure that every loop (Say it is running at 60 frames per second) I move it forward 1 unit.

I want it to render as many times as possible, but only move st a steady pace, but as smooth as possible
Ced666
Posts: 86
Joined: Fri Jan 13, 2006 10:29 am
Location: Belgium

Post by Ced666 »

Don't limit the frame rate. Instead, calculate the new position of your vehicle depending of the time elapsed since the last frame.
robpearmain
Posts: 12
Joined: Mon May 22, 2006 2:56 pm

Have you any sample code, even Pseudo

Post by robpearmain »

Thanks for your help

Looking at other code, this seems to work in C#.NET

Code: Select all

        private float _LastUpdate = 0.0f;
        
      public float CalculateMoveTween(IrrlichtDevice device)
      {
          //http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?p=68133

          // position += velocityPerMilisec * numberOfMiliSecsPassed; 

          ITimer timer = device.Timer;

          float thisupdate = timer.Time;
          float deltatime = ((thisupdate - _LastUpdate)/1000.0f);
          _LastUpdate = thisupdate;

          return deltatime;
      }
Post Reply