mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-28 16:43:29 +00:00
music settings work youhou
This commit is contained in:
@@ -39,15 +39,15 @@ namespace BBM
|
||||
this->_music.pause();
|
||||
}
|
||||
|
||||
void MusicComponent::setVolume(float &volumeUpdate)
|
||||
void MusicComponent::setVolume(float volumeUpdate)
|
||||
{
|
||||
if (volumeUpdate >= 0) {
|
||||
if (volumeUpdate >= 0 && volumeUpdate <= 1) {
|
||||
this->volume = volumeUpdate;
|
||||
this->_music.setVolume(this->volume);
|
||||
}
|
||||
}
|
||||
|
||||
void MusicComponent::setPitch(float &pitch)
|
||||
void MusicComponent::setPitch(float pitch)
|
||||
{
|
||||
this->_music.setPitch(pitch);
|
||||
}
|
||||
@@ -62,4 +62,14 @@ namespace BBM
|
||||
this->_music.updateMusicStream();
|
||||
}
|
||||
|
||||
void MusicComponent::turnDownVolume()
|
||||
{
|
||||
this->setVolume(MusicComponent::volume - 0.1);
|
||||
}
|
||||
|
||||
void MusicComponent::turnUpVolume()
|
||||
{
|
||||
this->setVolume(MusicComponent::volume + 0.1);
|
||||
}
|
||||
|
||||
} // namespace WAL
|
||||
|
||||
@@ -24,10 +24,16 @@ namespace BBM
|
||||
void pauseMusic();
|
||||
|
||||
//! @brief set music volume
|
||||
void setVolume(float &);
|
||||
void setVolume(float);
|
||||
|
||||
//! @brief volume -= 0.1
|
||||
void turnDownVolume();
|
||||
|
||||
//! @brief volume += 0.1
|
||||
void turnUpVolume();
|
||||
|
||||
//! @brief set pitch volume
|
||||
void setPitch(float &);
|
||||
void setPitch(float);
|
||||
|
||||
//! @brief is music playing
|
||||
bool isPlaying(void);
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include <Drawables/3D/Cube.hpp>
|
||||
#include <Drawables/2D/Rectangle.hpp>
|
||||
#include <Drawables/2D/Text.hpp>
|
||||
#include <Audio/Music.hpp>
|
||||
#include <Audio/Sound.hpp>
|
||||
#include <TraceLog.hpp>
|
||||
#include "System/Keyboard/KeyboardSystem.hpp"
|
||||
#include "System/Controllable/ControllableSystem.hpp"
|
||||
@@ -348,13 +350,19 @@ namespace BBM
|
||||
auto &musicUp = scene->addEntity("music up button")
|
||||
.addComponent<PositionComponent>(1920 / 1.5, 1080 - 540, 0)
|
||||
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_plus.png")
|
||||
.addComponent<OnClickComponent>()
|
||||
.addComponent<MusicComponent>("assets/musics/music_title.ogg")
|
||||
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
|
||||
{
|
||||
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
|
||||
|
||||
texture->use("assets/buttons/button_plus.png");
|
||||
})
|
||||
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &)
|
||||
{
|
||||
auto &component = entity.getComponent<MusicComponent>();
|
||||
|
||||
component.turnUpVolume();
|
||||
})
|
||||
.addComponent<OnHoverComponent>([](WAL::Entity &entity, WAL::Wal &)
|
||||
{
|
||||
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
|
||||
@@ -365,13 +373,19 @@ namespace BBM
|
||||
auto &musicDown = scene->addEntity("music down button")
|
||||
.addComponent<PositionComponent>(1920 / 3, 1080 - 540, 0)
|
||||
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_minus.png")
|
||||
.addComponent<OnClickComponent>()
|
||||
.addComponent<MusicComponent>("assets/musics/music_title.ogg")
|
||||
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
|
||||
{
|
||||
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
|
||||
|
||||
texture->use("assets/buttons/button_minus.png");
|
||||
})
|
||||
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &)
|
||||
{
|
||||
auto &component = entity.getComponent<MusicComponent>();
|
||||
|
||||
component.turnDownVolume();
|
||||
})
|
||||
.addComponent<OnHoverComponent>([](WAL::Entity &entity, WAL::Wal &)
|
||||
{
|
||||
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
|
||||
|
||||
Reference in New Issue
Block a user