mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-07 19:40:48 +00:00
fix sound on click
This commit is contained in:
@@ -23,7 +23,7 @@ namespace BBM
|
|||||||
{SoundComponent::JUMP, "assets/sounds/click.ogg"}
|
{SoundComponent::JUMP, "assets/sounds/click.ogg"}
|
||||||
};
|
};
|
||||||
|
|
||||||
addMenuControl(*scene);
|
addMenuControl(*scene, sounds);
|
||||||
scene->addEntity("background")
|
scene->addEntity("background")
|
||||||
.addComponent<PositionComponent>()
|
.addComponent<PositionComponent>()
|
||||||
.addComponent<Drawable2DComponent, RAY::Texture>("assets/plain_menu_background.png");
|
.addComponent<Drawable2DComponent, RAY::Texture>("assets/plain_menu_background.png");
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace BBM
|
|||||||
{SoundComponent::JUMP, "assets/sounds/click.ogg"}
|
{SoundComponent::JUMP, "assets/sounds/click.ogg"}
|
||||||
};
|
};
|
||||||
|
|
||||||
addMenuControl(*scene);
|
addMenuControl(*scene, sounds);
|
||||||
scene->addEntity("Control entity")
|
scene->addEntity("Control entity")
|
||||||
.addComponent<MusicComponent>("assets/musics/music_player_select.ogg")
|
.addComponent<MusicComponent>("assets/musics/music_player_select.ogg")
|
||||||
.addComponent<SoundComponent>(sounds);
|
.addComponent<SoundComponent>(sounds);
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace BBM
|
|||||||
};
|
};
|
||||||
auto scene = std::make_shared<WAL::Scene>();
|
auto scene = std::make_shared<WAL::Scene>();
|
||||||
|
|
||||||
addMenuControl(*scene);
|
addMenuControl(*scene, sounds);
|
||||||
scene->addEntity("Control entity")
|
scene->addEntity("Control entity")
|
||||||
.addComponent<MusicComponent>("assets/musics/music_player_select.ogg")
|
.addComponent<MusicComponent>("assets/musics/music_player_select.ogg")
|
||||||
.addComponent<SoundComponent>(sounds);
|
.addComponent<SoundComponent>(sounds);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace BBM
|
|||||||
};
|
};
|
||||||
auto scene = std::make_shared<WAL::Scene>();
|
auto scene = std::make_shared<WAL::Scene>();
|
||||||
|
|
||||||
addMenuControl(*scene);
|
addMenuControl(*scene, sounds);
|
||||||
scene->addEntity("Control entity")
|
scene->addEntity("Control entity")
|
||||||
.addComponent<MusicComponent>("assets/musics/music_title.ogg")
|
.addComponent<MusicComponent>("assets/musics/music_title.ogg")
|
||||||
.addComponent<SoundComponent>(sounds);
|
.addComponent<SoundComponent>(sounds);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace BBM
|
|||||||
};
|
};
|
||||||
auto scene = std::make_shared<WAL::Scene>();
|
auto scene = std::make_shared<WAL::Scene>();
|
||||||
|
|
||||||
addMenuControl(*scene);
|
addMenuControl(*scene, sounds);
|
||||||
scene->addEntity("Control entity")
|
scene->addEntity("Control entity")
|
||||||
.addComponent<MusicComponent>("assets/musics/music_player_select.ogg")
|
.addComponent<MusicComponent>("assets/musics/music_player_select.ogg")
|
||||||
.addComponent<SoundComponent>(sounds);
|
.addComponent<SoundComponent>(sounds);
|
||||||
|
|||||||
@@ -110,17 +110,20 @@ namespace BBM
|
|||||||
.addSystem<RenderSystem>(window);
|
.addSystem<RenderSystem>(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Runner::addMenuControl(WAL::Scene &scene)
|
void Runner::addMenuControl(WAL::Scene &scene, const std::map<SoundComponent::SoundIndex, std::string> &sounds)
|
||||||
{
|
{
|
||||||
scene.addEntity("Keyboard default control")
|
scene.addEntity("Keyboard default control")
|
||||||
.addComponent<ControllableComponent>()
|
.addComponent<ControllableComponent>()
|
||||||
|
.addComponent<SoundComponent>(sounds)
|
||||||
.addComponent<KeyboardComponent>();
|
.addComponent<KeyboardComponent>();
|
||||||
scene.addEntity("Keyboard second control")
|
scene.addEntity("Keyboard second control")
|
||||||
.addComponent<ControllableComponent>()
|
.addComponent<ControllableComponent>()
|
||||||
|
.addComponent<SoundComponent>(sounds)
|
||||||
.addComponent<KeyboardComponent>(ControllableComponent::Layout::KEYBOARD_1);
|
.addComponent<KeyboardComponent>(ControllableComponent::Layout::KEYBOARD_1);
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
scene.addEntity("Gamepad controller")
|
scene.addEntity("Gamepad controller")
|
||||||
.addComponent<ControllableComponent>()
|
.addComponent<ControllableComponent>()
|
||||||
|
.addComponent<SoundComponent>(sounds)
|
||||||
.addComponent<GamepadComponent>(i);
|
.addComponent<GamepadComponent>(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Models/GameState.hpp"
|
#include "Models/GameState.hpp"
|
||||||
#include "Wal.hpp"
|
#include "Wal.hpp"
|
||||||
|
#include <map>
|
||||||
|
#include "Component/Sound/SoundComponent.hpp"
|
||||||
|
|
||||||
namespace BBM
|
namespace BBM
|
||||||
{
|
{
|
||||||
@@ -30,7 +32,7 @@ namespace BBM
|
|||||||
//! @brief init all raylib-related data & context
|
//! @brief init all raylib-related data & context
|
||||||
static void enableRaylib(WAL::Wal &wal);
|
static void enableRaylib(WAL::Wal &wal);
|
||||||
|
|
||||||
static void addMenuControl(WAL::Scene &scene);
|
static void addMenuControl(WAL::Scene &scene, const std::map<SoundComponent::SoundIndex, std::string> &sounds = {});
|
||||||
|
|
||||||
//! @brief load all data related to title screen
|
//! @brief load all data related to title screen
|
||||||
static std::shared_ptr<WAL::Scene> loadTitleScreenScene();
|
static std::shared_ptr<WAL::Scene> loadTitleScreenScene();
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace BBM
|
|||||||
playersIconPath.push_back(path.replace(path.find("textures"), std::string("textures").size(), "icons"));
|
playersIconPath.push_back(path.replace(path.find("textures"), std::string("textures").size(), "icons"));
|
||||||
}
|
}
|
||||||
|
|
||||||
addMenuControl(*scene);
|
addMenuControl(*scene, sounds);
|
||||||
scene->addEntity("Audio ressources")
|
scene->addEntity("Audio ressources")
|
||||||
.addComponent<MusicComponent>("assets/musics/music_result.ogg")
|
.addComponent<MusicComponent>("assets/musics/music_result.ogg")
|
||||||
.addComponent<SoundComponent>(sounds);
|
.addComponent<SoundComponent>(sounds);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace BBM
|
|||||||
{SoundComponent::JUMP, "assets/sounds/click.ogg"}
|
{SoundComponent::JUMP, "assets/sounds/click.ogg"}
|
||||||
};
|
};
|
||||||
|
|
||||||
addMenuControl(*scene);
|
addMenuControl(*scene, sounds);
|
||||||
scene->addEntity("Control entity")
|
scene->addEntity("Control entity")
|
||||||
.addComponent<MusicComponent>("assets/musics/music_title.ogg")
|
.addComponent<MusicComponent>("assets/musics/music_title.ogg")
|
||||||
.addComponent<SoundComponent>(sounds);
|
.addComponent<SoundComponent>(sounds);
|
||||||
@@ -110,6 +110,7 @@ namespace BBM
|
|||||||
.addComponent<PositionComponent>(1920 / 1.5, 1080 - 360, 0)
|
.addComponent<PositionComponent>(1920 / 1.5, 1080 - 360, 0)
|
||||||
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_plus.png")
|
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_plus.png")
|
||||||
.addComponent<SoundComponent>(sounds)
|
.addComponent<SoundComponent>(sounds)
|
||||||
|
.addComponent<ControllableComponent>()
|
||||||
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &)
|
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &)
|
||||||
{
|
{
|
||||||
auto &component = entity.getComponent<SoundComponent>();
|
auto &component = entity.getComponent<SoundComponent>();
|
||||||
@@ -133,6 +134,7 @@ namespace BBM
|
|||||||
.addComponent<PositionComponent>(1920 / 3, 1080 - 360, 0)
|
.addComponent<PositionComponent>(1920 / 3, 1080 - 360, 0)
|
||||||
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_minus.png")
|
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_minus.png")
|
||||||
.addComponent<SoundComponent>(sounds)
|
.addComponent<SoundComponent>(sounds)
|
||||||
|
.addComponent<ControllableComponent>()
|
||||||
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
|
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
|
||||||
{
|
{
|
||||||
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
|
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace BBM
|
|||||||
{SoundComponent::JUMP, "assets/sounds/click.ogg"}
|
{SoundComponent::JUMP, "assets/sounds/click.ogg"}
|
||||||
};
|
};
|
||||||
auto scene = std::make_shared<WAL::Scene>();
|
auto scene = std::make_shared<WAL::Scene>();
|
||||||
addMenuControl(*scene);
|
addMenuControl(*scene, sounds);
|
||||||
scene->addEntity("control")
|
scene->addEntity("control")
|
||||||
.addComponent<SoundComponent>(sounds)
|
.addComponent<SoundComponent>(sounds)
|
||||||
.addComponent<MusicComponent>("assets/musics/music_title.ogg");
|
.addComponent<MusicComponent>("assets/musics/music_title.ogg");
|
||||||
|
|||||||
Reference in New Issue
Block a user