summary refs log tree commit diff stats
path: root/src/interpolation.cpp
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2021-03-13 07:25:23 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2021-03-13 15:34:50 -0500
commit142e00794097dfb78c4b758a2d39d26fae070092 (patch)
tree72ca6327cf5d1658573ab112b397f2f28992062a /src/interpolation.cpp
parent3c505f6f7fa5d4fab7c2a2864a45c8f5d0b4d329 (diff)
downloadtanetane-142e00794097dfb78c4b758a2d39d26fae070092.tar.gz
tanetane-142e00794097dfb78c4b758a2d39d26fae070092.tar.bz2
tanetane-142e00794097dfb78c4b758a2d39d26fae070092.zip
Created Interpolation abstraction
This simplifies EffectSystem quite a bit, and will be useful in other classes.
Diffstat (limited to 'src/interpolation.cpp')
-rw-r--r--src/interpolation.cpp19
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
3void Interpolation::start(int length, double amount) {
4 start_ = progress_;
5 dest_ = amount;
6 length_ = length;
7 thus_ = 0;
8}
9
10void 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}