Skip to content

Instantly share code, notes, and snippets.

@vermie
Created January 8, 2011 08:56
Show Gist options
  • Save vermie/770697 to your computer and use it in GitHub Desktop.
Save vermie/770697 to your computer and use it in GitHub Desktop.
timer
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