KlassischeKeplerKriege/game/state/missile.hpp

69 lines
1.6 KiB
C++
Raw Normal View History

#pragma once
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
#include "state.hpp"
#include "ship.hpp"
#include "planet.hpp"
namespace game {
class State;
// missile belongs to a player and optionally fills a trace behind it.
// trace then belongs to the player.
class Missile {
public:
enum class HitObject {
Nothing,
HitPlayer,
HitPlanet,
// HitMissile,
LeftUniverse
};
// missile advances to pos. if hit != Nothing, it hits something and
// stops existing afterwards.
class Event {
public:
Event(const glm::vec2 &pos) : Event(pos, HitObject::Nothing)
{
}
Event(const glm::vec2 &pos, HitObject hit)
: hit(hit), pos(pos)
{
}
Event(const glm::vec2 &pos, int playerIdKiller, int playerIdVictim)
: Event(pos, HitObject::HitPlayer)
{
this->playerIdKiller = playerIdKiller;
this->playerIdVictim = playerIdVictim;
}
HitObject hit;
glm::vec2 pos;
int playerIdKiller;
int playerIdVictim;
};
// XXX
int playerId; // owner won't be hit by own missiles
glm::vec2 position;
glm::vec2 velocity;
//Trace *trace;
Missile(int playerId, const glm::vec2 &pos, float angle, float speed);
~Missile();
// try to advance. if something will be hit, return the first hit in
// time.
Missile::Event advance(const game::State *state, float dt);
};
}