summaryrefslogtreecommitdiffhomepage
path: root/Timeline.cpp
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-05-21 11:55:08 +0200
committerAki <please@ignore.pl>2022-05-21 11:55:08 +0200
commit7863e4caa1d07aef348a437fe0a662db68fd7ac3 (patch)
treebf52dfa7a7c45be1d1a696f5bf7c0c3f90beba68 /Timeline.cpp
parentde8d7a812c4da9f0375dc47626c0e836ba728207 (diff)
downloadderelict-7863e4caa1d07aef348a437fe0a662db68fd7ac3.zip
derelict-7863e4caa1d07aef348a437fe0a662db68fd7ac3.tar.gz
derelict-7863e4caa1d07aef348a437fe0a662db68fd7ac3.tar.bz2
Added naive Timeline
Diffstat (limited to 'Timeline.cpp')
-rw-r--r--Timeline.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/Timeline.cpp b/Timeline.cpp
new file mode 100644
index 0000000..b6003e5
--- /dev/null
+++ b/Timeline.cpp
@@ -0,0 +1,40 @@
+#include "Timeline.h"
+
+#include <algorithm>
+#include <ctime>
+
+
+Timeline::Timeline(const std::time_t start, const std::time_t end) :
+ m_start {start},
+ m_end {static_cast<double>(end - start)},
+ m_current {0.0}
+{
+}
+
+
+std::time_t
+Timeline::timestamp() const
+{
+ return m_start + m_current;
+}
+
+
+double
+Timeline::current() const
+{
+ return m_current;
+}
+
+
+double
+Timeline::progress() const
+{
+ return m_current / m_end;
+}
+
+
+double
+Timeline::move(const double dt)
+{
+ return m_current = std::clamp(m_current + dt, 0.0, m_end);
+}