KlassischeKeplerKriege/game/state/commands.cpp
2016-09-27 20:13:09 +02:00

32 lines
840 B
C++

#include "commands.hpp"
#include "trace.hpp"
namespace game {
void ShootCommand::apply(Player *player, State *state) const
{
//std::cout<<"apply command " << name() << std::endl;
// TODO: idea
// shoot multiple rockets at once or from different positions after
// level up / upgrade ...
Missile *missile = new Missile(player, player->ship->position, m_angle, m_speed);
Trace *trace = new Trace(missile);
missile->trace = trace;
player->energy -= m_speed;
player->missiles.push_back(missile);
state->addTrace(trace);
}
bool ShootCommand::allowed(const Player *player, const State *state) const
{
(void) state;
// TODO
return player->alive && player->energy >= m_speed;
//return player->alive;
}
}