diff --git a/sources/Component/IntroAnimation/IntroAnimationComponent.cpp b/sources/Component/IntroAnimation/IntroAnimationComponent.cpp new file mode 100644 index 00000000..261a168e --- /dev/null +++ b/sources/Component/IntroAnimation/IntroAnimationComponent.cpp @@ -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); + } +} \ No newline at end of file diff --git a/sources/Component/IntroAnimation/IntroAnimationComponent.hpp b/sources/Component/IntroAnimation/IntroAnimationComponent.hpp new file mode 100644 index 00000000..694b875a --- /dev/null +++ b/sources/Component/IntroAnimation/IntroAnimationComponent.hpp @@ -0,0 +1,40 @@ +#pragma once + +#include + +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; + }; +} diff --git a/sources/System/IntroAnimation/IntroAnimationSystem.cpp b/sources/System/IntroAnimation/IntroAnimationSystem.cpp new file mode 100644 index 00000000..74f3a89a --- /dev/null +++ b/sources/System/IntroAnimation/IntroAnimationSystem.cpp @@ -0,0 +1,46 @@ + +#include +#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 + +namespace RAY2D = RAY::Drawables::Drawables2D; + +namespace BBM +{ + IntroAnimationSystem::IntroAnimationSystem(WAL::Wal &wal) + : System(wal), wal(wal) + {} + + void IntroAnimationSystem::onFixedUpdate(WAL::ViewEntity &entity) + { + auto &component = entity.get(); + auto &scene = wal.getScene(); + + switch (component.currentStep) + { + case IntroAnimationComponent::animationSteps::init: + scene->addEntity("white background") + .addComponent(BBM::Vector2f(), BBM::Vector2f(1920, 1080), WHITE); + + scene->addEntity("blinking square").addComponent(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) + { + } +} \ No newline at end of file diff --git a/sources/System/IntroAnimation/IntroAnimationSystem.hpp b/sources/System/IntroAnimation/IntroAnimationSystem.hpp new file mode 100644 index 00000000..1a266443 --- /dev/null +++ b/sources/System/IntroAnimation/IntroAnimationSystem.hpp @@ -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 + { + private: + //! @brief reference to wal + WAL::Wal &wal; + + public: + //! @inherit + void onSelfUpdate(void) override; + + //! @inherit + void onFixedUpdate(WAL::ViewEntity &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; + }; +} \ No newline at end of file