diff options
Diffstat (limited to 'src/common.hpp')
-rw-r--r-- | src/common.hpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/common.hpp b/src/common.hpp index 181139f..6042e08 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -260,6 +260,7 @@ namespace game { void start(void); void stop(void); void tick(ntime_t time); + void compute_ambience(render::state_t *render); void pause(void); void resume(void); @@ -389,11 +390,14 @@ namespace render { void render_line(v2f_t x0, v2f_t x1, sf::Color color); void debug_path(v2f_t x, std::list<v2f_t> *path); + + rectf_t window_in_world_space(void); }; } namespace audio { void clean_sounds(void); + void update_ambience(bool playing); class sound_t { sf::SoundBuffer buffer; @@ -402,6 +406,15 @@ namespace audio { void load(const char *path); void play(void); }; + + class ambient_t { + public: + sf::Music sound; + bool playing = false; + float weight = 0.0f; + + void load(const char *path); + }; } extern render::state_t *debug_render; @@ -429,6 +442,23 @@ T lerp(T a, T b, T x) return a * (1 - x) + b * x; } +// Linear map between intervals. +template <typename T> +T remap(T am, T ap, T bm, T bp, T x) +{ + return (x - am) * (bp - bm) / (ap - am) + bm; +} + +template <typename T> +T clamp(T x, T m, T p) +{ + if (x < m) + return m; + if (x > p) + return p; + return x; +} + // Bilinear interpolation. template <typename T> T bilerp(T a, T b, T c, T d, T x, T y) |