gametime Class Reference

Tehe gametime class makes the speed of the game independent of the machine it runs on. More...

#include <gametime.h>

List of all members.

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.


Detailed Description

Tehe gametime class makes the speed of the game independent of the machine it runs 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.


Member Function Documentation

void gametime::init ( u_int16  rt_minutes  )  [static]

Initialize the gametime class.

Parameters:
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.

Returns:
gametime in minutes.

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.

Returns:
number of updates to perform before drawing a frame.
See also:
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.

See also:
frames_to_skip ()

Definition at line 49 of file gametime.cc.


The documentation for this class was generated from the following files:

Generated on Wed Jun 18 16:24:05 2008 for Adonthell by  doxygen 1.5.6