Brunot
Loading...
Searching...
No Matches
ac Namespace Reference

Variables

static const std::function LinearEase
static const std::function TranslateAction
static const std::function ScaleAction
static const std::function SetColorAction
static const std::function easeInOutBack
static const std::function easeOutElastic
static const std::function easeOutBounce
static const std::function EaseInOutBounce

Variable Documentation

◆ easeInOutBack

const std::function ac::easeInOutBack
inlinestatic
Initial value:
= [](float current, float total)
{
constexpr auto c1 = 1.70158f;
constexpr auto c2 = c1 * 1.525f;
auto progress = current / total;
if (progress < 0.5f)
{
return (pow(2 * total, 2) * ((c2 + 1) * 2 * total - c2)) / 2;
}
return (pow(2 * total - 2, 2) * ((c2 + 1) * (total * 2 - 2) + c2) + 2) / 2;
}
Todo
: test out easeInOutBack and easeOutElastic

◆ EaseInOutBounce

const std::function ac::EaseInOutBounce
inlinestatic
Initial value:
= [](float current, float total)
{
return current < 0.5f
? (1 - easeOutBounce(total, 1 - 2 * current)) / 2
: (1 + easeOutBounce(total, 2 * current - 1)) / 2;
}
static const std::function easeOutBounce
Definition Action.h:178

◆ easeOutBounce

const std::function ac::easeOutBounce
inlinestatic
Initial value:
= [](float current, float total)
{
constexpr auto n1 = 7.5625f;
if (current < 1 / total)
{
return n1 * current * current;
}
if (current < 2 / total)
{
return n1 * (current -= 1.5f / total) * current + 0.75f;
}
if (current < 2.5f / total)
{
return n1 * (current -= 2.25f / total) * current + 0.9375f;
}
return n1 * (current -= 2.625f / total) * current + 0.984375f;
}
Todo
Fix the easeBounce functions

◆ easeOutElastic

const std::function ac::easeOutElastic
inlinestatic
Initial value:
= [](float current, float total)
{
auto progress = current / total;
if (progress == 0 || progress == 1)
{
return progress;
}
return static_cast<float>(pow(2, -10 * progress) * sin((progress * 10 - 0.75f) * (2 * std::numbers::pi / 3.f)) + 1);
}

◆ LinearEase

const std::function ac::LinearEase
inlinestatic
Initial value:
= [](float current, float total)
{
return current / total;
}

◆ ScaleAction

const std::function ac::ScaleAction
inlinestatic
Initial value:
= [](GameObject* parent, const Vector4D& newScale)
{
assert(parent && "TranslateAction given a nullptr");
if (auto parentAsEntity = dynamic_cast<Entity*>(parent))
{
if (auto parentTransform = parentAsEntity->GetComponent<Transform>(Component::cTransform))
{
parentTransform->scale(newScale);
}
}
}
@ cTransform
Definition Component.h:39
Definition Entity.h:33
the base class for the engine, most things inherit from this.
Definition GameObject.h:77
Definition Transform.h:27
Definition Vector4D.h:23

◆ SetColorAction

const std::function ac::SetColorAction
inlinestatic
Initial value:
= [](GameObject* parent, const Vector4D& newColor)
{
assert(parent && "SetColorAction given a nullptr");
if (auto parentAsEntity = dynamic_cast<Entity*>(parent))
{
if (auto parentSprite = parentAsEntity->GetComponent<Sprite>(Component::cSprite))
{
parentSprite->color() = newColor;
}
}
}
@ cSprite
Definition Component.h:41
A component that renders an image on an entity, or text.
Definition Sprite.h:34

◆ TranslateAction

const std::function ac::TranslateAction
inlinestatic
Initial value:
= [](GameObject* parent, const Point2D& newTranslation)
{
assert(parent && "TranslateAction given a nullptr");
if (auto parentAsEntity = dynamic_cast<Entity*>(parent))
{
if (auto parentTransform = parentAsEntity->GetComponent<Transform>(Component::cTransform))
{
parentTransform->translation(newTranslation);
}
}
}
Vector4D Point2D
Definition Transform.h:21
Todo
: Add more easing functions and actions