added volume control

This commit is contained in:
Joseph Aquino 2025-09-24 22:13:43 -04:00
parent ef7fffb159
commit d7dcb2425e
2 changed files with 11 additions and 3 deletions

View File

@ -111,6 +111,7 @@ private:
int totalSpecialBricks{}; int totalSpecialBricks{};
int totalBricks{}; int totalBricks{};
int framerate{}; int framerate{};
float volume{10};
float playerSpeed{}; float playerSpeed{};
float ballRadius{}; float ballRadius{};
float ballMaxSpeed{}; float ballMaxSpeed{};

View File

@ -49,9 +49,9 @@ Game::Game()
window.setFramerateLimit(framerate); window.setFramerateLimit(framerate);
collideSound.setVolume(50); collideSound.setVolume(volume);
brickBreakSound.setVolume(50); brickBreakSound.setVolume(volume);
failSound.setVolume(50); failSound.setVolume(volume);
player.pos = playerStartPos; player.pos = playerStartPos;
playerHalfSize = playerSize / 2.f; playerHalfSize = playerSize / 2.f;
@ -479,6 +479,13 @@ void Game::imgui()
ImGui::Text("R: reset game"); ImGui::Text("R: reset game");
ImGui::Unindent(); ImGui::Unindent();
if (ImGui::SliderFloat("Game Volume", &volume, 0, 100, "%.1f"))
{
collideSound.setVolume(volume);
brickBreakSound.setVolume(volume);
failSound.setVolume(volume);
}
ImGui::Text("Level config:"); ImGui::Text("Level config:");
if(ImGui::InputInt("Total bricks", &totalBricks)) if(ImGui::InputInt("Total bricks", &totalBricks))
{ {