KlassischeKeplerKriege/game/state/trace.cpp

45 lines
910 B
C++
Raw Normal View History

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