Closed RyanCLuis closed 9 months ago
okay did some rearranging and have this
function playMusic () {
let tile = event.target // gets selected tile
// checkes to see if head emoji is selected
if (tile.innerText === "🥴") {
return
}
if (tile.innerText === "🧠") {
let audio = new Audio("soundEffects/splat.mp3")
audio.play()
} if (gameOver) {
return
} else {
let audio = new Audio("soundEffects/gun.mp3")
audio.play()
}
}
and with this everything plays and stops except when i hit the 🧠it still plays audio but all other tiles dont, how do i get all audio to stop playing
neverminded, fixed the issue after messing with it! I tried moving the gameOver function around and was getting different results i didn't want, so i decided to make a new function the when a mind was revealed it played an audio and i called upon that function in the realMinds function
What's the problem you're trying to solve?
with the code i have, it plays both audio file when i want it to (ie when i hit a tile and when a 🧠is hit) as well as when i am placing a 🥴 the sounds dont play. When i add a if statement (ie , if (gameOver) {return} ) so you cant keep clicking a tile and hear the sound. it bugs my 🧠sound to where i cant hear it.
Post any code you think might be relevant (one fenced block per file)
this is the first block before i add the gameOver function and audio is working
this is the eventListener to play the audio
If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?
What is your best guess as to the source of the problem?
Na
What things have you already tried to solve the problem?
i tried making a new function called playBrainAudio and having it pass through the revealMinds function but still nothing
Paste a link to your repository here
https://github.com/RyanCLuis/Minesweeper/tree/v2