This repository has been archived on 2019-12-07. You can view files and clone it, but cannot push or open issues or pull requests.
dungeon-gunner/source/util/Timer.cpp
2012-12-22 01:14:30 +01:00

48 lines
675 B
C++

/*
* Timer.cpp
*
* Created on: 19.10.2012
* Author: Felix
*/
#include "Timer.h"
#include <assert.h>
/**
* Initializes time limit to zero.
*/
Timer::Timer() {
}
/**
* Initializes time limit to parameter value.
*/
Timer::Timer(sf::Time timeLimit) :
mLimit(timeLimit) {
}
/**
* Returns true if the time set in setLimit() has passed since calling start().
*/
bool
Timer::isExpired() const {
return mClock.getElapsedTime() >= mLimit;
}
/**
* Starts the timer.
*/
void
Timer::start() {
mClock.restart();
}
/**
* Sets the time limit to run to.
*/
void
Timer::setLimit(sf::Time timeLimit) {
assert(timeLimit > sf::Time::Zero);
mLimit = timeLimit;
}