diff options
Diffstat (limited to 'src/interpolation.cpp')
-rw-r--r-- | src/interpolation.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/interpolation.cpp b/src/interpolation.cpp new file mode 100644 index 0000000..3c9bcf8 --- /dev/null +++ b/src/interpolation.cpp | |||
@@ -0,0 +1,19 @@ | |||
1 | #include "interpolation.h" | ||
2 | |||
3 | void Interpolation::start(int length, double amount) { | ||
4 | start_ = progress_; | ||
5 | dest_ = amount; | ||
6 | length_ = length; | ||
7 | thus_ = 0; | ||
8 | } | ||
9 | |||
10 | void Interpolation::tick(double dt) { | ||
11 | if (progress_ != dest_) { | ||
12 | thus_ += dt; | ||
13 | if (thus_ >= length_) { | ||
14 | thus_ = length_; | ||
15 | } | ||
16 | |||
17 | progress_ = (dest_ - start_) / length_ * thus_ + start_; | ||
18 | } | ||
19 | } | ||