#include <gametime.h>
Static Public Member Functions | |
static void | init (u_int16 rt_minutes) |
Initialize the gametime class. | |
static double | minute () |
Return the in-game time that passed since the last call to this method. | |
static void | start_action () |
static void | stop_action () |
Methods to sync the game speed to the machine it runs on | |
static u_int8 | frames_to_skip () |
Returns the number of updates to perform before drawing the next frame. | |
static void | update () |
Call this after each run of the main loop to sync the game's speed to the machine it is running on. |
This is achieved by keeping the number of updates to the game state constant, no matter how fast or slow the machine. This won't work for very slow machines of course, but Adonthell will still be playable on a 100 Ghz CPU.
Definition at line 61 of file gametime.h.
void gametime::init | ( | u_int16 | rt_minutes | ) | [static] |
Initialize the gametime class.
rt_minutes | Defines how many real life minutes make one gametime day. |
Definition at line 32 of file gametime.cc.
static double gametime::minute | ( | ) | [inline, static] |
Return the in-game time that passed since the last call to this method.
Definition at line 78 of file gametime.h.
static u_int8 gametime::frames_to_skip | ( | ) | [inline, static] |
Returns the number of updates to perform before drawing the next frame.
That is, it returns the number of frames to skip. If the box Adonthell runs on is sufficiently fast, this number will be 0. On slower machines, it can be as high as FTS_LIMIT.
Definition at line 113 of file gametime.h.
void gametime::update | ( | ) | [static] |
Call this after each run of the main loop to sync the game's speed to the machine it is running on.
On faster machines it delays the execution and for slower boxes it calculates the number of frames to skip. If the engine should do 50 frames per second, for example, but the main loop takes 26ms to perform, every second frame will be skipped to keep the game' speed constant. It also updates the internal clock.
Definition at line 49 of file gametime.cc.