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.
42 lines
1.3 KiB
C++
42 lines
1.3 KiB
C++
#include "classicflyinganimationscenario.h"
|
|
#include "graphics/classicnotegraphics.h"
|
|
|
|
void ClassicFlyingAnimationScenario::launch(
|
|
const std::shared_ptr<ClassicNoteGraphics> sprite,
|
|
const kku::microsec &time_begin, const kku::microsec &time_end)
|
|
{
|
|
_sprite = sprite;
|
|
_time_begin = time_begin;
|
|
_time_end = time_end;
|
|
|
|
_percentage = ((_time_end - _time_begin) * 0.01);
|
|
|
|
_sprite->setTrailColor(_sprite->getColor());
|
|
}
|
|
|
|
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;
|
|
}
|