diff options
Diffstat (limited to 'src/common.hpp')
-rw-r--r-- | src/common.hpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/common.hpp b/src/common.hpp index 7221b44..87706c8 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -266,13 +266,16 @@ namespace interface { float em; struct { + v2f_t zero_point_s = v2f_t(0, 0); v2f_t center = v2f_t(0, 0); - int target_zoom = 3; - float zoom = 3.0f; + + int zoom = 3; + float zoom_s = 3.0f; + bool panning = false; sf::Vector2f pan_ref; + bool following = true; - v2f_t follow_center = v2f_t(0, 0); } camera; struct { @@ -290,6 +293,8 @@ namespace interface { double perf_hist[10] = {0}; size_t perf_hist_index = 0; + void start_following(void); + void stop_following(void); public: state_t(sf::RenderWindow *window_, game::state_t *game); void tick(double dt); @@ -408,7 +413,14 @@ T bilerp(T a, T b, T c, T d, T x, T y) return lerp(ab, cd, y); } -static inline float expfade(float a, float b, float l, float dt) +template <typename T> +static inline void expfade(T *a, T b, T l, T dt) +{ + *a = b + (*a - b) * exp(-l * dt); +} + +template <typename T, size_t N> +static inline void expfade(vec_t<T, N> *a, vec_t<T, N> b, float l, float dt) { - return b + (a - b) * exp(-l * dt); + *a = b + (*a - b) * exp(-l * dt); } |