Skip to content

Commit

Permalink
add a sound bar
Browse files Browse the repository at this point in the history
  • Loading branch information
Farru049 committed Dec 21, 2024
1 parent f7bd98e commit b45a84e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
14 changes: 14 additions & 0 deletions css/tower.css
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,17 @@ body {
margin-right: 42.5%;
margin-left: 42.5%;
}
.sound-bar {
margin-top: 10px;
display: flex;
align-items: center;
}

.sound-bar label {
margin-right: 10px;
font-size: 14px;
}

#volume-control {
width: 100px;
}
4 changes: 4 additions & 0 deletions html/tower.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ <h2>what do you want to do next?</h2>
</button>
<h2>Would you like to play music?</h2>
<button class="btn-agree link">yes!!!</button>
<div class="sound-bar">
<label for="volume-control">Volume:</label>
<input type="range" id="volume-control" min="0" max="1" step="0.1" value="0.5" />
</div>
</div>

<footer class="game-score">
Expand Down
18 changes: 17 additions & 1 deletion js/tower.js
Original file line number Diff line number Diff line change
Expand Up @@ -621,4 +621,20 @@ function gradientAnimation() {

function displayScore(){
document.querySelector('#score-span').innerHTML = gameState.score;
}
}
document.querySelector('.btn-close').addEventListener('click', () => {
modalMusicAgreement.hide();
});

document.querySelector('.btn-agree').addEventListener('click', () => {
modalMusicAgreement.hide();
music.isPlayMusic = true;
music.background.volume = 0.5; // Set default volume
music.background.play();
});

const volumeControl = document.getElementById('volume-control');
volumeControl.addEventListener('input', (event) => {
const volume = event.target.value;
music.background.volume = volume; // Adjust the music volume
});

0 comments on commit b45a84e

Please sign in to comment.