KlassischeKeplerKriege/game/state/explosion.hpp

38 lines
1,005 B
C++
Raw Normal View History

#pragma once
2016-09-27 17:32:12 +00:00
#include <glm/vec2.hpp>
#include "util.hpp"
#include "missile_hit_type.hpp"
2016-09-27 17:32:12 +00:00
namespace game {
/**
* Explosion: just an effect which looks good.
*/
class Explosion {
public:
Explosion(const glm::vec2 &pos, Hit hit, float maxAge=1.0)
: hit(hit)
, position(pos)
, age(0.0)
, maxAge(maxAge * (1.0 + 0.1*util::randf_0_1()))
, maxRadius(0.05)
2016-09-27 17:32:12 +00:00
{
2016-09-30 18:19:10 +00:00
static size_t id_counter = 0;
id = id_counter++;
2016-09-27 17:32:12 +00:00
}
const Hit hit; // kind of the explosion depends on the hit type
2016-09-27 17:32:12 +00:00
const glm::vec2 position; // position where it starts
float age; // age (in seconsd) of the explosion
2016-09-27 17:32:12 +00:00
// age (in seconds) when the explosion is not visible
// anymore and will disappear afterwards
const float maxAge;
const float maxRadius; // current radius depends on time.
2016-09-30 18:19:10 +00:00
size_t id;
2016-09-27 17:32:12 +00:00
};
}