From 4b6e5eb5d3e0733c239a7a231da91a9977c38246 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 12 Mar 2022 14:12:42 -0500 Subject: dynamic wall and floor textures --- src/interpolation.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/interpolation.h (limited to 'src/interpolation.h') 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 @@ +#ifndef INTERPOLATION_H_861230A8 +#define INTERPOLATION_H_861230A8 + +class Interpolation { +public: + + void start(int length) { + length_ = length; + thus_ = 0; + } + + void tick(double dt) { + if (thus_ < length_) { + thus_ += dt; + if (thus_ >= length_) { + thus_ = length_; + } + } + } + + // Info + + double getProgress(double from, double to) const { + return (to - from) / length_ * thus_ + from; + } + + bool isComplete() const { return thus_ == length_; } + +private: + + double progress_ = 0.0; + double dest_ = 0.0; + double start_ = 0.0; + double length_ = 0.0; + double thus_ = 0.0; +}; + +#endif /* end of include guard: INTERPOLATION_H_861230A8 */ -- cgit 1.4.1