zengine/include/ZE_ZTimer.h

113 lines
2.9 KiB
C
Raw Normal View History

/*******************************************************************************
2002-12-29 06:50:19 +00:00
This file is Part of the ZEngine Library for 2D game development.
Copyright (C) 2002, 2003 James Turk
2002-12-29 06:50:19 +00:00
Licensed under a BSD-style license.
2002-12-29 06:50:19 +00:00
The maintainer of this library is James Turk (james@conceptofzero.net)
and the home of this Library is http://www.zengine.sourceforge.net
*******************************************************************************/
/*!
\file ZE_ZTimer.h
\brief Definition file for ZTimer.
Definition file for ZTimer, the Timer class for ZEngine.
2003-05-13 01:30:50 +00:00
<br>$Id: ZE_ZTimer.h,v 1.8 2003/05/13 01:30:51 cozman Exp $<br>
2003-05-07 20:34:50 +00:00
\author James Turk
**/
#ifndef __ze_ztimer_h__
#define __ze_ztimer_h__
2003-02-10 04:02:38 +00:00
#include "ZE_ZEngine.h"
namespace ZE
{
/*!
\brief ZTimer class for Timer use.
ZTimer timing class, class wraps common features of SDL timer. Inherited from ZObject and tied to ZEngine main timer.
**/
2003-02-10 04:02:38 +00:00
class ZTimer
{
protected:
2003-02-10 04:02:38 +00:00
//! Pointer to ZEngine Object
ZEngine* rEngine;
//! Paused / Unpaused state of Timer
bool rPaused;
//! Using ZEngine timer or SDL global timer.
bool rUseZEngine;
//! Total time this timer has been paused.
Uint32 rPausedTime;
//! Time this Timer was paused.
Uint32 rLastPause;
/*!
\brief Get time from parent timer.
Protected method to get time from whichever timer is parent.
\return Time on parent timer.
**/
2003-01-16 05:45:58 +00:00
Uint32 GetParentTime() const;
public:
/*!
\brief Constructs a new Timer.
Sets TimePaused to current ZEngine time if useZEngine is true, otherwise uses SDL timer.
\param useZEngine Tells if timer should use ZEngine or SDL.
**/
ZTimer(bool useZEngine=true);
2003-02-10 04:40:16 +00:00
/*!
\brief Virtual Destructor.
Virtual destructor making future inheritance safe.
**/
virtual ~ZTimer();
/*!
\brief Reset Timer.
Set Timer back to Zero, will also unpause timer if it was paused.
**/
void Reset();
/*!
\brief Pause Timer.
Pause the timer if it is unpaused.
**/
void Pause();
/*!
\brief Unpause Timer.
Unpause the timer if it is paused.
**/
void Unpause();
/*!
\brief Get Time of Timer.
Get current time accounting for time paused.
\return Current Timer Time.
**/
2003-01-16 05:45:58 +00:00
Uint32 GetTime() const;
/*!
\brief Get paused state.
Find out paused state of timer.
\return Paused state for timer.
**/
2003-01-16 05:45:58 +00:00
bool IsPaused() const;
};
}
#endif //__ze_ztimer_h__