12. Time

Chapters

Commonly case, game have kind of time are real time and virtual time, that mean is real time cannot stop in any conditions, the Time going straight and don't backward even if you need but you cannot.

Virtual time have difference point, you can pause, run, reset or play back on that if you want because this time is simulation from game loop and don't get that from real world.

How to get value of time on Arsa framework that you can doing by follows:

 

12.1 Get virtual time.

      A.) value return as millisecond(1, 000 millisecond = 1 second)

irr::u32 timeMS = g_device->getTimer()->getTime();

 

      B.) Checking pass time.

irr::u32 firstTime = 0; // declare as global

// keep first time, writting in game loop.

if (firstTime == 0)

firstTime = g_device->getTimer()->getTime();

irr::u32 timeMS = g_device->getTimer()->getTime(); // get current time

// example: need checking 3 second pass.

if ((timeMS - firstTime) > 3000)

{

      // do something,

      // maybe reset firstTime to zero if you want keep that again.

}

 

12.2 Get real time.

      A.) value return as millisecond(1, 000 millisecond = 1 second)         

irr::u32 timeMS = g_device->getTimer()->getRealTime();

 

NOTE: Almost case in-game time use virtual time instead real time. Real time use when testing game performance or benchmark process e.g. checking loading psd time that can do following:

irr::u32 startLoad = g_device->getTimer()->getRealTime();

g_psd->load("test.psd");

// loadTime is delta time in millisecond.

irr::u32 loadTime = g_device->getTimer()->getRealTime() - startLoad;

Tags: