KlassischeKeplerKriege/game/state/trace.cpp
2016-09-27 23:07:11 +02:00

44 lines
910 B
C++

#include "trace.hpp"
#include <glm/gtx/norm.hpp>
#include "missile.hpp"
#include <iostream>
namespace game {
Trace::TracePoint::TracePoint(const Missile *missile)
: position(missile->position)
, speed(glm::length(missile->velocity))
{
}
Trace::~Trace()
{
//std::cout<<"~Trace()" << std::endl;
}
Trace::Trace(Missile *missile)
: missile(missile)
, player(missile->player)
, fidelityCounter(0)
, age(0.0)
{
points.push_back(TracePoint(missile));
}
void Trace::addPointFromMissile(bool forceAdd)
{
fidelityCounter++;
if (forceAdd || fidelityCounter >= 10) {
fidelityCounter = 0;
points.push_back(TracePoint(missile));
}
}
void Trace::finish()
{
//std::cout<<"trace finished now!" << std::endl;
missile = nullptr;
}
}