Created
January 8, 2011 08:56
-
-
Save vermie/770697 to your computer and use it in GitHub Desktop.
timer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct LightTimer | |
{ | |
public: | |
LightTimer() : i_expiryTime(0) {} | |
explicit LightTimer(uint32 expiry) : i_expiryTime(expiry) {} | |
//if Update() returns true - timer has elapsed | |
//and you should call Reset() method | |
bool Elapsed(uint32 diff) { return (i_expiryTime -= diff) < 0; } | |
void Reset(uint32 interval) { i_expiryTime += interval; } | |
uint32 TimeLeft() const { return i_expiryTime; } | |
private: | |
int32 i_expiryTime; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment