skizzle/src/utility.cpp

16 lines
372 B
C++

#include <cmath>
#include "manager.hpp"
#include "utility.hpp"
float Utility::animateValue(float current, float speed, float goal) {
float gap = goal - current;
float diff = gap * Manager::FRAME_TIME.asSeconds() * speed;
// si on est très proches de la fin, on termine
if (std::abs(gap) < .1f) {
return goal;
}
return current + diff;
}