You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.3 KiB
C++

#include "classicnoteactivestate.h"
#include "../classicnote.h"
#include "../classicsprite.h"
auto ClassicNoteActiveState::value() const -> Value
{
return Value::ACTIVE;
}
auto ClassicNoteActiveState::update(const ClassicNote* note, const microsec& offset) -> Value
{
float i;
auto update_time = offset - note->getApearanceTime(); // This all will be inside ::update
i = update_time / note->getOneTrailPercent() * 0.01; // of an animation object
const auto& coordinates = note->getCoordinates();
const auto& sprite = note->sprite();
float xa = getPt( coordinates.x + 20. , coordinates.x + 90. , i );
float ya = getPt( coordinates.y - 600. , coordinates.y - 150. , i );
float xb = getPt( coordinates.x + 90. , coordinates.x , i );
float yb = getPt( coordinates.y - 150. , coordinates.y , i );
sprite->update(getPt( xa , xb , i ), getPt( ya , yb , i ));
if (i >= 1)
{
sprite->trailFade();
}
if (!note->isActive(offset))
return Value::DYING;
return value();
}
constexpr int ClassicNoteActiveState::getPt(float n1, float n2, float perc) const
{
float diff = n2 - n1;
return n1 + (diff * perc);
}
void ClassicNoteActiveState::onEntering(const ClassicNote* note)
{
(void)note;
}