mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-31 01:25:21 +00:00
add intro animation
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// Created by Zoe Roux on 5/24/21.
|
||||
//
|
||||
|
||||
#include "IntroAnimationComponent.hpp"
|
||||
|
||||
namespace BBM
|
||||
{
|
||||
IntroAnimationComponent::IntroAnimationComponent(WAL::Entity &entity)
|
||||
: WAL::Component(entity)
|
||||
{}
|
||||
|
||||
WAL::Component *IntroAnimationComponent::clone(WAL::Entity &entity) const
|
||||
{
|
||||
return new IntroAnimationComponent(entity);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include <Component/Component.hpp>
|
||||
|
||||
namespace BBM
|
||||
{
|
||||
//! @brief A component to slowly center entities to the middle of their current block.
|
||||
//! This allow flexibility in their movement will preventing them from getting stuck at every corner.
|
||||
class IntroAnimationComponent : public WAL::Component
|
||||
{
|
||||
public:
|
||||
unsigned int frame = 0;
|
||||
|
||||
enum animationSteps {
|
||||
init,
|
||||
boxBlinking,
|
||||
topLeftgrowing,
|
||||
bottomRightGrowing,
|
||||
lettersTyping,
|
||||
fading,
|
||||
prompt,
|
||||
};
|
||||
|
||||
enum animationSteps currentStep = init;
|
||||
|
||||
//! @inherit
|
||||
Component *clone(WAL::Entity &entity) const override;
|
||||
|
||||
//! @brief Create a new, default IntroAnimationComponent.
|
||||
//! @param entity The entity attached to this component.
|
||||
explicit IntroAnimationComponent(WAL::Entity &entity);
|
||||
//! @brief A IntroAnimationComponent is copy constructable
|
||||
//! @param other The other IntroAnimationComponent to copy.
|
||||
IntroAnimationComponent(const IntroAnimationComponent &other) = default;
|
||||
//! @brief A default destructor
|
||||
~IntroAnimationComponent() override = default;
|
||||
//! @brief A IntroAnimationComponent is not assignable
|
||||
IntroAnimationComponent &operator=(const IntroAnimationComponent &) = delete;
|
||||
};
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user