Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members

peon::Timer Class Reference

This object as a way to properly control animation and other effects in our scene relying on the "timing" in the game. More...

#include <Timer.h>

List of all members.

Public Member Functions

 Timer ()
 Constructor.
 ~Timer ()
 Destructor.
void reset ()
 This method resets the timer.
void start ()
 This method starts the timer.
void stop ()
 This method is used to stop/pause the timer.
void advance ()
 This method is used to incrementally advance the timer by 0.1 seconds.
float getAbsoluteTime ()
 This method returns the absolute system time.
float getTime ()
 This method returns the current time.
float getElapsedTime ()
 This method returns the time that has elapsed between getElapsedTime.
bool isStopped ()
 This method just returns if our timer is active or not.

Protected Attributes

bool m_bUsingQPF
 are we using the high performance timer?
bool m_bTimerStopped
 is the timer stopped?
LONGLONG m_llQPFTicksPerSec
 LONGLONG for ticks/sec.
LONGLONG m_llStopTime
LONGLONG m_llLastElapsedTime
LONGLONG m_llBaseTime


Detailed Description

This object as a way to properly control animation and other effects in our scene relying on the "timing" in the game.

Every frame of the game, we update this object with a snapshot of the current clock of the CPU in order to create a delta (differential) with the last clock snapshot. This delta controls the movement of the objects in our gameworld.

To make this object more platform independent, feel free to investigate using the SDL timer functions

Note that on some newer multi-processor systems, the QPC doesn't always cut the mustard. Depending upon your app, the resolution of timeGetTime() might be enough for your object animation...

It really just takes some experimentation folks..


Member Function Documentation

float peon::Timer::getAbsoluteTime  ) 
 

This method returns the absolute system time.

Returns:
float - absolute system time

float peon::Timer::getElapsedTime  ) 
 

This method returns the time that has elapsed between getElapsedTime.

Returns:
float - the time delta

float peon::Timer::getTime  ) 
 

This method returns the current time.

Returns:
float - the current time

bool peon::Timer::isStopped  ) 
 

This method just returns if our timer is active or not.

Returns:
bool - true if timer is stopped


The documentation for this class was generated from the following file:
Generated on Thu Dec 1 01:55:41 2005 for Peon by  doxygen 1.4.1