#include <CClock.h>
Public Member Functions | |
CClock (void) | |
Constructor (does nothing). | |
~CClock (void) | |
Destructor (does nothing). | |
void | Create (EClockType ClockType, EClockMode ClockMode, int Hours, int Minutes, int Seconds, int Seconds100) |
Initialize the clock. | |
void | Destroy (void) |
Uninitialize the clock. | |
void | Update (float DeltaTime) |
Update the clock's date. | |
void | Reset (void) |
Reset the date to the starting date (which was set on last call to Create()). | |
void | Pause (void) |
Pause the clock. | |
void | Resume (void) |
Resume the clock. | |
int | GetHours (void) |
Get the Hour component of the current date. | |
int | GetMinutes (void) |
Get the Minute component of the current date. | |
int | GetSeconds (void) |
Get the Second component of the current date. | |
int | GetSeconds100 (void) |
Get the Second100 component of the current date. | |
Private Member Functions | |
void | CountHours (float &RemainingDate) |
Count the hours in the remaining date by decreasing the given date and incrementing the hours count progressively. | |
void | CountMinutes (float &RemainingDate) |
Count the minutes in the remaining date by decreasing the given date and incrementing the minutes count progressively. | |
void | CountSeconds (float &RemainingDate) |
Count the seconds in the remaining date by decreasing the given date and incrementing the seconds count progressively. | |
void | CountSeconds100 (float &RemainingDate) |
Count the seconds100 in the remaining date by decreasing the given date and incrementing the seconds100 count progressively. | |
Private Attributes | |
float | m_Date |
Most accurate available date. | |
int | m_Hours |
Hours count in the date, according to clock mode. | |
int | m_Minutes |
Minutes count in the date, according to clock mode. | |
int | m_Seconds |
Seconds count in the date, according to clock mode. | |
int | m_Seconds100 |
Seconds100 count in the date, according to clock mode. | |
int | m_StartHours |
Hours count to start with and to use when resetting (Reset method). | |
int | m_StartMinutes |
Minutes count to start with and to use when resetting (Reset method). | |
int | m_StartSeconds |
Seconds count to start with and to use when resetting (Reset method). | |
int | m_StartSeconds100 |
Seconds100 count to start with and to use when resetting (Reset method). | |
EClockType | m_ClockType |
Type of the clock. | |
EClockMode | m_ClockMode |
Mode of the clock. | |
bool | m_Pause |
Update the date (or not) when calling Update method. |
You have to periodically update the clock after creating it. You then just have to get the "date parts" (hours/minutes/seconds/seconds100) according to the clock mode you chose.
Basic use of the CClock class
// Make a CClock object CClock Clock; // Initialize the clock. Clock.Create (CLOCKTYPE_COUNTDOWN, // We want a count down clock CLOCKMODE_MSC, // We want to be able to extract these date // components : minutes, seconds, seconds100. 3, // Initialize the hours component of the clock 54, // Initialize the minutes component of the clock 32, // Initialize the seconds component of the clock 0); // Initialize the seconds100 component of the clock // Main loop while (...) { //... // Tell the clock how many seconds elapsed since last update Clock.Update (FloatDeltaTime); // You can now extract the components of the clock's date int Minutes = Clock.GetMinutes(); int Seconds = Clock.GetSeconds(); int Seconds100 = Clock.GetSeconds100(); // Here if the update didn't change the clock's date, // we would have : Date = 3 * 3600 + 54 * 60 + 32 + 0 * 0.010f = 14072 seconds // So : // Minutes = 234 // Seconds = 32 // Seconds100 = 0 //... } // Uninitialize the clock since we don't need it anymore Clock.Destroy ();
CClock::CClock | ( | void | ) |
Constructor (does nothing).
CClock::~CClock | ( | void | ) |
Destructor (does nothing).
void CClock::CountHours | ( | float & | RemainingDate | ) | [private] |
Count the hours in the remaining date by decreasing the given date and incrementing the hours count progressively.
void CClock::CountMinutes | ( | float & | RemainingDate | ) | [private] |
Count the minutes in the remaining date by decreasing the given date and incrementing the minutes count progressively.
void CClock::CountSeconds | ( | float & | RemainingDate | ) | [private] |
Count the seconds in the remaining date by decreasing the given date and incrementing the seconds count progressively.
void CClock::CountSeconds100 | ( | float & | RemainingDate | ) | [private] |
Count the seconds100 in the remaining date by decreasing the given date and incrementing the seconds100 count progressively.
void CClock::Create | ( | EClockType | ClockType, | |
EClockMode | ClockMode, | |||
int | Hours, | |||
int | Minutes, | |||
int | Seconds, | |||
int | Seconds100 | |||
) |
Initialize the clock.
void CClock::Destroy | ( | void | ) |
Uninitialize the clock.
void CClock::Update | ( | float | DeltaTime | ) |
Update the clock's date.
void CClock::Reset | ( | void | ) |
Reset the date to the starting date (which was set on last call to Create()).
void CClock::Pause | ( | void | ) | [inline] |
Pause the clock.
void CClock::Resume | ( | void | ) | [inline] |
Resume the clock.
int CClock::GetHours | ( | void | ) | [inline] |
Get the Hour component of the current date.
int CClock::GetMinutes | ( | void | ) | [inline] |
Get the Minute component of the current date.
int CClock::GetSeconds | ( | void | ) | [inline] |
Get the Second component of the current date.
int CClock::GetSeconds100 | ( | void | ) | [inline] |
Get the Second100 component of the current date.
float CClock::m_Date [private] |
Most accurate available date.
int CClock::m_Hours [private] |
Hours count in the date, according to clock mode.
int CClock::m_Minutes [private] |
Minutes count in the date, according to clock mode.
int CClock::m_Seconds [private] |
Seconds count in the date, according to clock mode.
int CClock::m_Seconds100 [private] |
Seconds100 count in the date, according to clock mode.
int CClock::m_StartHours [private] |
Hours count to start with and to use when resetting (Reset method).
int CClock::m_StartMinutes [private] |
Minutes count to start with and to use when resetting (Reset method).
int CClock::m_StartSeconds [private] |
Seconds count to start with and to use when resetting (Reset method).
int CClock::m_StartSeconds100 [private] |
Seconds100 count to start with and to use when resetting (Reset method).
EClockType CClock::m_ClockType [private] |
Type of the clock.
EClockMode CClock::m_ClockMode [private] |
Mode of the clock.
bool CClock::m_Pause [private] |
Update the date (or not) when calling Update method.