mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-30 01:05:24 +00:00
sound playing at end of intro
This commit is contained in:
@@ -4,7 +4,11 @@
|
||||
#include "System/IntroAnimation/IntroAnimationSystem.hpp"
|
||||
#include "Entity/Entity.hpp"
|
||||
#include "Component/Renderer/Drawable2DComponent.hpp"
|
||||
#include "Component/Controllable/ControllableComponent.hpp"
|
||||
#include <Drawables/2D/Rectangle.hpp>
|
||||
#include <Drawables/2D/Text.hpp>
|
||||
#include "Runner/Runner.hpp"
|
||||
#include "Component/Music/MusicComponent.hpp"
|
||||
|
||||
namespace RAY2D = RAY::Drawables::Drawables2D;
|
||||
|
||||
@@ -20,6 +24,10 @@ namespace BBM
|
||||
auto &component = entity.get<IntroAnimationComponent>();
|
||||
auto scene = wal.getScene();
|
||||
RAY2D::Rectangle *rectangle = nullptr;
|
||||
RAY2D::Text *text = nullptr;
|
||||
static auto &rayText = scene->addEntity("raylibtext Rectangle")
|
||||
.addComponent<PositionComponent>(1920 / 2 - 44, 1080 / 2 + 48, 0)
|
||||
.addComponent<Drawable2DComponent, RAY2D::Text>("", 50, RAY::Vector2(), BLACK);
|
||||
static auto &bottomRectangle = scene->addEntity("bottom Rectangle")
|
||||
.addComponent<PositionComponent>(1920 / 2 - 128, 1080 / 2 - 128, 0)
|
||||
.addComponent<Drawable2DComponent, RAY2D::Rectangle>(logoPos, RAY::Vector2(16, 16), BLACK);
|
||||
@@ -32,6 +40,7 @@ namespace BBM
|
||||
static auto &topRectangle = scene->addEntity("top Rectangle")
|
||||
.addComponent<PositionComponent>(1920 / 2 - 128, 1080 / 2 - 128, 0)
|
||||
.addComponent<Drawable2DComponent, RAY2D::Rectangle>(logoPos, RAY::Vector2(16, 16), BLACK);
|
||||
static short letterCounter = 0;
|
||||
|
||||
switch (component.currentStep)
|
||||
{
|
||||
@@ -40,7 +49,7 @@ namespace BBM
|
||||
topRectangle.getComponent<Drawable2DComponent>().drawable->setColor(BLACK);
|
||||
else
|
||||
topRectangle.getComponent<Drawable2DComponent>().drawable->setColor(WHITE);
|
||||
if (component.frameCounter == 120) {
|
||||
if (component.frameCounter == 60) {
|
||||
component.currentStep = IntroAnimationComponent::animationSteps::topLeftgrowing;
|
||||
component.frameCounter = -1;
|
||||
topRectangle.getComponent<Drawable2DComponent>().drawable->setColor(BLACK);
|
||||
@@ -63,8 +72,24 @@ namespace BBM
|
||||
rectangle->incrementWidth(4);
|
||||
rectangle = dynamic_cast<RAY2D::Rectangle *>(rightRectangle.getComponent<Drawable2DComponent>().drawable.get());
|
||||
rectangle->incrementHeight(4);
|
||||
if (rectangle->getHeight() == 256)
|
||||
if (rectangle->getHeight() == 256) {
|
||||
component.currentStep = IntroAnimationComponent::animationSteps::lettersTyping;
|
||||
component.frameCounter = 0;
|
||||
}
|
||||
break;
|
||||
case IntroAnimationComponent::animationSteps::lettersTyping:
|
||||
if ((component.frameCounter / 15) % 2) {
|
||||
letterCounter++;
|
||||
text = dynamic_cast<RAY2D::Text *>(rayText.getComponent<Drawable2DComponent>().drawable.get());
|
||||
if (letterCounter == 2) {
|
||||
scene->addEntity("startup sound")
|
||||
.addComponent<MusicComponent>("assets/sounds/splash_sound.ogg")
|
||||
.getComponent<MusicComponent>().playMusic();
|
||||
}
|
||||
text->setText(std::string("raylib").substr(0, letterCounter));
|
||||
}
|
||||
if (component.frameCounter == 60)
|
||||
Runner::gameState.nextScene = Runner::gameState.TitleScreenScene;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user