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.
50 lines
1.5 KiB
C++
50 lines
1.5 KiB
C++
#include "classicnoteflyingstate.h"
|
|
#include "../classicnote.h"
|
|
#include "../classicsprite.h"
|
|
|
|
auto ClassicNoteFlyingState::value() const -> Value
|
|
{
|
|
return Value::FLYING;
|
|
}
|
|
|
|
auto ClassicNoteFlyingState::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::ACTIVE;
|
|
|
|
return value();
|
|
}
|
|
|
|
constexpr int ClassicNoteFlyingState::getPt(float n1, float n2, float perc) const
|
|
{
|
|
float diff = n2 - n1;
|
|
return n1 + (diff * perc);
|
|
}
|
|
|
|
void ClassicNoteFlyingState::onEntering(const ClassicNote* note)
|
|
{
|
|
const auto& coordinates = note->getCoordinates();
|
|
const auto& sprite = note->sprite();
|
|
|
|
sprite->setCoordinates(coordinates.x, coordinates.y,
|
|
coordinates.x + 20, coordinates.y - 600);
|
|
}
|
|
|