summaryrefslogtreecommitdiff
path: root/timedLatch.cpp
diff options
context:
space:
mode:
authorStephen Enders <smenders@gmail.com>2021-01-20 21:05:44 -0500
committerStephen Enders <smenders@gmail.com>2021-01-20 21:05:44 -0500
commiteccb6df404b9ae052b9d13750f54dc69241668b4 (patch)
treeec4c52c55c021a4550723f2fe8fd6dce8c118ac2 /timedLatch.cpp
parent1f8159534f30d3e46f53cebb788c91153103edcb (diff)
Create timer and use it to end the rolling phase
This timer can be used to determine when to end rolling
Diffstat (limited to 'timedLatch.cpp')
-rw-r--r--timedLatch.cpp37
1 files changed, 37 insertions, 0 deletions
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;
+};
+
+}