summaryrefslogtreecommitdiff
path: root/src/common.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common.hpp')
-rw-r--r--src/common.hpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/common.hpp b/src/common.hpp
index f89ae08..df14f6f 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -175,7 +175,7 @@ namespace game {
class unit_t;
class state_t {
- double now;
+ double now, dt;
std::unordered_set<unit_t*> units;
std::unordered_set<unit_t*> selected_units;
@@ -185,7 +185,7 @@ namespace game {
void start(void);
void stop(void);
- void tick(double now_);
+ void tick(double now_, double dt_);
// These are called by the interface.
void select(rectf_t rect);
@@ -213,7 +213,7 @@ namespace interface {
public:
state_t(sf::RenderWindow *window_, game::state_t *game);
- void tick(void);
+ void tick(double dt);
void render_to(render::state_t *render);
};
}
@@ -264,10 +264,10 @@ namespace render {
void drender_text(rectf_t rect, std::string str);
void drender_entity(world::entity_t *ent);
public:
- double now;
+ double now, dt;
state_t(sf::RenderWindow *window_);
- void begin_frame(double time_);
+ void begin_frame(double time_, double dt_);
void end_frame(void);
void render(game::state_t *game);
void render(animated_texture_t *anim, rectf_t bounds, bool mirror = false);
@@ -333,3 +333,8 @@ T bilerp(T a, T b, T c, T d, T x, T y)
cd = lerp(c, d, x);
return lerp(ab, cd, y);
}
+
+static inline float expfade(float a, float b, float l, float dt)
+{
+ return b + (a - b) * exp(-l * dt);
+}