add intro animation

This commit is contained in:
arthur.jamet
2021-06-10 15:10:14 +02:00
parent ffccdf6fcb
commit 57f9d5446a
4 changed files with 134 additions and 0 deletions
@@ -0,0 +1,46 @@
#include <algorithm>
#include "Component/Button/ButtonComponent.hpp"
#include "Component/Position/PositionComponent.hpp"
#include "System/IntroAnimation/IntroAnimationSystem.hpp"
#include "Component/Controllable/ControllableComponent.hpp"
#include "Entity/Entity.hpp"
#include "Component/Renderer/Drawable2DComponent.hpp"
#include <Drawables/2D/Rectangle.hpp>
namespace RAY2D = RAY::Drawables::Drawables2D;
namespace BBM
{
IntroAnimationSystem::IntroAnimationSystem(WAL::Wal &wal)
: System(wal), wal(wal)
{}
void IntroAnimationSystem::onFixedUpdate(WAL::ViewEntity<IntroAnimationComponent> &entity)
{
auto &component = entity.get<IntroAnimationComponent>();
auto &scene = wal.getScene();
switch (component.currentStep)
{
case IntroAnimationComponent::animationSteps::init:
scene->addEntity("white background")
.addComponent<Drawable2DComponent, RAY2D::Rectangle>(BBM::Vector2f(), BBM::Vector2f(1920, 1080), WHITE);
scene->addEntity("blinking square").addComponent<Drawable2DComponent, RAY2D::Rectangle>(BBM::Vector2f(), BBM::Vector2f(16, 16), WHITE);
component.currentStep = IntroAnimationComponent::animationSteps::boxBlinking;
break;
case IntroAnimationComponent::animationSteps::boxBlinking:
if ((component.frame / 15) % 2)
scene->getEntities()
break;
}
component.frame++;
}
void IntroAnimationSystem::onSelfUpdate(void)
{
}
}
@@ -0,0 +1,31 @@
#pragma once
#include "Component/IntroAnimation/IntroAnimationComponent.hpp"
#include "System/System.hpp"
namespace BBM
{
//! @brief A system to handle Controllable entities in a menu.
class IntroAnimationSystem : public WAL::System<IntroAnimationComponent>
{
private:
//! @brief reference to wal
WAL::Wal &wal;
public:
//! @inherit
void onSelfUpdate(void) override;
//! @inherit
void onFixedUpdate(WAL::ViewEntity<IntroAnimationComponent> &entities) override;
//! @brief A default constructor
IntroAnimationSystem(WAL::Wal &wal);
//! @brief A IntroAnimation system is not copy constructable
IntroAnimationSystem(const IntroAnimationSystem &) = delete;
//! @brief A default destructor
~IntroAnimationSystem() override = default;
//! @brief A IntroAnimation system is assignable.
IntroAnimationSystem &operator=(const IntroAnimationSystem &) = default;
};
}