summary refs log tree commit diff stats
path: root/src/interpolation.cpp
blob: 3c9bcf8d9e62fd44631275ec8f69efc73758223c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "interpolation.h"

void Interpolation::start(int length, double amount) {
  start_ = progress_;
  dest_ = amount;
  length_ = length;
  thus_ = 0;
}

void Interpolation::tick(double dt) {
  if (progress_ != dest_) {
    thus_ += dt;
    if (thus_ >= length_) {
      thus_ = length_;
    }

    progress_ = (dest_ - start_) / length_ * thus_ + start_;
  }
}