Skip to content

Commit 7ced6da

Browse files
SemphrissYour Name
and
Your Name
authored
Animate the parachute and bubblegum shield (#5306)
Co-authored-by: Your Name <[email protected]>
1 parent 502fcf5 commit 7ced6da

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

src/items/attachment.cpp

+28-3
Original file line numberDiff line numberDiff line change
@@ -617,9 +617,34 @@ void Attachment::updateGraphics(float dt)
617617
World::getWorld()->getTicksSinceStart()) / 0.7f;
618618
if (scale_ratio > 0.0f)
619619
{
620-
float scale = 0.3f * scale_ratio +
621-
wanted_node_scale * (1.0f - scale_ratio);
622-
m_node->setScale(core::vector3df(scale, scale, scale));
620+
if (m_type == ATTACH_PARACHUTE)
621+
{
622+
const float progress = 1.0f - scale_ratio;
623+
624+
const float x = 0.2f * atan(25.0f * progress - 5.0f) + 0.69f;
625+
const float y = x;
626+
const float z = 1.0f - pow(2.0f, -20.f * progress);
627+
628+
m_node->setScale(core::vector3df(x * wanted_node_scale,
629+
y * wanted_node_scale,
630+
z * wanted_node_scale));
631+
}
632+
else
633+
{
634+
if (is_shield)
635+
{
636+
// Taken from https://easings.net/#easeInElastic
637+
const float c4 = (2.0f * PI) / 3.0f;
638+
const float x = scale_ratio;
639+
640+
scale_ratio = x <= 0 ? 0 : x >= 1 ? 1
641+
: -pow(2, 10 * x - 10) * sin((x * 10 - 10.75) * c4);
642+
}
643+
644+
float scale = 0.3f * scale_ratio +
645+
wanted_node_scale * (1.0f - scale_ratio);
646+
m_node->setScale(core::vector3df(scale, scale, scale));
647+
}
623648
}
624649
else
625650
{

0 commit comments

Comments
 (0)