summaryrefslogtreecommitdiff
path: root/src/timedLatch.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/timedLatch.cpp')
-rw-r--r--src/timedLatch.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/timedLatch.cpp b/src/timedLatch.cpp
new file mode 100644
index 0000000..66714a5
--- /dev/null
+++ b/src/timedLatch.cpp
@@ -0,0 +1,38 @@
+#include "timedLatch.hpp"
+
+namespace ur {
+
+TimedLatch::TimedLatch(sf::Time duration)
+{
+ this->duration = duration;
+ this->clock = sf::Clock();
+ this->isStarted = false;
+};
+
+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;
+};
+
+}