KlassischeKeplerKriege/game/state/trace.cpp

47 lines
984 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-29 07:32:56 +00:00
Trace::Trace(Missile *missile, float maxAge)
2016-09-27 21:07:11 +00:00
: missile(missile)
, player(missile->player)
, fidelityCounter(0)
, age(0.0)
2016-09-29 07:32:56 +00:00
, maxAge(maxAge)
2016-09-27 17:43:40 +00:00
{
points.push_back(TracePoint(missile));
}
2016-09-29 07:32:56 +00:00
Trace::~Trace()
{
//std::cout<<"~Trace()" << std::endl;
}
void Trace::addPointFromMissile(bool forceAdd)
2016-09-27 17:43:40 +00:00
{
2016-09-29 11:11:01 +00:00
// TODO: make configurable
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
}