2021-12-29 09:59:18 -05:00
|
|
|
#include "classicflyinganimationscenario.h"
|
2022-03-10 12:45:19 -05:00
|
|
|
#include "graphics/classicnotegraphics.h"
|
2021-12-29 09:59:18 -05:00
|
|
|
|
2022-03-10 12:45:19 -05:00
|
|
|
void ClassicFlyingAnimationScenario::launch(const std::shared_ptr<ClassicNoteGraphics> sprite, const kku::microsec& time_begin, const kku::microsec &time_end)
|
2021-12-29 09:59:18 -05:00
|
|
|
{
|
|
|
|
_sprite = sprite;
|
|
|
|
_time_begin = time_begin;
|
|
|
|
_time_end = time_end;
|
|
|
|
|
|
|
|
_percentage = ((_time_end - _time_begin) * 0.01);
|
2022-05-25 22:13:13 -04:00
|
|
|
|
2022-05-25 22:42:56 -04:00
|
|
|
_sprite->setTrailColor(_sprite->getColor());
|
2021-12-29 09:59:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
float ClassicFlyingAnimationScenario::getPoint(const kku::Point& point, float perc) const
|
|
|
|
{
|
|
|
|
return point.x + ((point.y - point.x) * perc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClassicFlyingAnimationScenario::update(const kku::microsec& music_offset)
|
|
|
|
{
|
|
|
|
const auto crd = _sprite->getPosition();
|
|
|
|
auto update_time = music_offset - _time_begin;
|
|
|
|
float i = update_time / _percentage * 0.01;
|
|
|
|
|
|
|
|
float xa = getPoint(kku::Point{crd.x + 20, crd.x + 90}, i);
|
|
|
|
float ya = getPoint(kku::Point{crd.y - 600, crd.y - 150}, i);
|
|
|
|
float xb = getPoint(kku::Point{crd.x + 90, crd.x}, i);
|
|
|
|
float yb = getPoint(kku::Point{crd.y - 150, crd.y}, i);
|
|
|
|
|
|
|
|
_sprite->setTrailPosition(kku::Point(getPoint( kku::Point{xa, xb}, i ), getPoint( kku::Point{ya, yb}, i )));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ClassicFlyingAnimationScenario::isDone() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|