From eccb6df404b9ae052b9d13750f54dc69241668b4 Mon Sep 17 00:00:00 2001 From: Stephen Enders Date: Wed, 20 Jan 2021 21:05:44 -0500 Subject: Create timer and use it to end the rolling phase This timer can be used to determine when to end rolling --- timedLatch.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 timedLatch.cpp (limited to 'timedLatch.cpp') diff --git a/timedLatch.cpp b/timedLatch.cpp new file mode 100644 index 0000000..0629ac8 --- /dev/null +++ b/timedLatch.cpp @@ -0,0 +1,37 @@ +#include "timedLatch.hpp" + +namespace ur { + +TimedLatch::TimedLatch(sf::Time duration) +{ + this->duration = duration; + this->clock = sf::Clock(); +}; + +void +TimedLatch::start() +{ + this->clock.restart(); + this->isStarted = true; +}; + +bool +TimedLatch::is_running() +{ + return this->isStarted && this->clock.getElapsedTime() < duration; +}; + +bool +TimedLatch::is_completed() +{ + + return this->isStarted && this->clock.getElapsedTime() >= duration; +}; + +void +TimedLatch::reset() +{ + this->isStarted = false; +}; + +} -- cgit v1.2.3-54-g00ecf