KlassischeKeplerKriege/game/state/explosion.hpp
2016-09-30 20:19:10 +02:00

37 lines
1,005 B
C++

#pragma once
#include <glm/vec2.hpp>
#include "util.hpp"
#include "missile_hit_type.hpp"
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)
{
static size_t id_counter = 0;
id = id_counter++;
}
const Hit hit; // kind of the explosion depends on the hit type
const glm::vec2 position; // position where it starts
float age; // age (in seconsd) of the explosion
// 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.
size_t id;
};
}