2016-09-27 16:23:58 +00:00
|
|
|
#pragma once
|
|
|
|
|
2016-09-27 17:32:12 +00:00
|
|
|
#include <glm/vec2.hpp>
|
|
|
|
|
2016-09-27 19:16:55 +00:00
|
|
|
#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:
|
2016-09-27 19:16:55 +00:00
|
|
|
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-27 16:23:58 +00:00
|
|
|
|
2016-09-27 19:16:55 +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 16:23:58 +00:00
|
|
|
|
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;
|
2016-09-27 19:16:55 +00:00
|
|
|
const float maxRadius; // current radius depends on time.
|
2016-09-27 17:32:12 +00:00
|
|
|
};
|
|
|
|
}
|