summary refs log tree commit diff stats
path: root/src/interpolation.h
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2022-03-12 14:12:42 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2022-03-12 14:12:42 -0500
commit4b6e5eb5d3e0733c239a7a231da91a9977c38246 (patch)
tree90b18271f180c56efc9995458714b2b0aa3725fc /src/interpolation.h
parentbe9ccb73bc20b03f62c77f5d529602a10ef4eda9 (diff)
downloadether-4b6e5eb5d3e0733c239a7a231da91a9977c38246.tar.gz
ether-4b6e5eb5d3e0733c239a7a231da91a9977c38246.tar.bz2
ether-4b6e5eb5d3e0733c239a7a231da91a9977c38246.zip
dynamic wall and floor textures
Diffstat (limited to 'src/interpolation.h')
-rw-r--r--src/interpolation.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/interpolation.h b/src/interpolation.h new file mode 100644 index 0000000..68a6221 --- /dev/null +++ b/src/interpolation.h
@@ -0,0 +1,38 @@
1#ifndef INTERPOLATION_H_861230A8
2#define INTERPOLATION_H_861230A8
3
4class Interpolation {
5public:
6
7 void start(int length) {
8 length_ = length;
9 thus_ = 0;
10 }
11
12 void tick(double dt) {
13 if (thus_ < length_) {
14 thus_ += dt;
15 if (thus_ >= length_) {
16 thus_ = length_;
17 }
18 }
19 }
20
21 // Info
22
23 double getProgress(double from, double to) const {
24 return (to - from) / length_ * thus_ + from;
25 }
26
27 bool isComplete() const { return thus_ == length_; }
28
29private:
30
31 double progress_ = 0.0;
32 double dest_ = 0.0;
33 double start_ = 0.0;
34 double length_ = 0.0;
35 double thus_ = 0.0;
36};
37
38#endif /* end of include guard: INTERPOLATION_H_861230A8 */