diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt index 35f1f0a..8d2e44f 100644 --- a/game/CMakeLists.txt +++ b/game/CMakeLists.txt @@ -15,6 +15,8 @@ set(GAME_SRC util.cpp game.cpp state/object.cpp + state/explosion.cpp + state/trace.cpp state/state.cpp state/player.cpp state/planet.cpp diff --git a/game/state/explosion.hpp b/game/state/explosion.hpp index 2cf92ef..66c234f 100644 --- a/game/state/explosion.hpp +++ b/game/state/explosion.hpp @@ -1,17 +1,32 @@ #pragma once -#if 0 -class Explosion { -public: - enum class Kind { - Normal, - MissileWithShip +#include + +namespace game { + /** + * Explosion: just an effect which looks good. + */ + class Explosion { + public: + enum class Kind { + MissileExplodesInSpace, // missile explode in free space + MissileAgainstPlanet, // explosion of missile when it hits a planet + MissileAgainstShip // bigger explosion: missile hits a ship which explodes with it + }; + + Explosion(const glm::vec2 &pos, Kind kind, float maxAge=1.0) + : position(pos), kind(kind), age(0.0), maxAge(maxAge) + { + } + + const Kind kind; // kind of the explosion + 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; }; +} - glm::vec2 position; - - Explosion(Kind kind); - -public: -}; #endif diff --git a/game/state/trace.cpp b/game/state/trace.cpp new file mode 100644 index 0000000..e69de29 diff --git a/game/state/trace.hpp b/game/state/trace.hpp new file mode 100644 index 0000000..5c7f050 --- /dev/null +++ b/game/state/trace.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include + +namespace game { + /* + * Trace of a missile through the space. + * Useful for rendering sth. like a smoke trail to follow the rocket. + */ + class Trace { + public: + Trace(const glm::vec2 &startPoint) + { + points.push_back(startPoint); + } + + void addPoint(const glm::vec2 &p) + { + points.push_back(p); + } + + std::vector points; + }; +}