Skip to content

Commit 84f960d

Browse files
Added sounds
1 parent 32f4321 commit 84f960d

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

html/game.html

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<img src="orange2.jpg" style="display:none;" alt="" />
3131
<img src="orange3.jpg" style="display:none;" alt="" />
3232
<img src="orange4.jpg" style="display:none;" alt="" />
33-
33+
<div id="dummy" style="display: none;"></div>
3434
<h1 id="scorecount" style="color: black; padding-left: 20px"> </h1> <!--// Create the score count display element -->
3535
<center>
3636
<h1 class="words" style="font-family: captcha"></h1> <!--
@@ -74,16 +74,21 @@ <h1 class="win2" style="display: none"></h1> <!--// Cre
7474
{
7575
name: "Orange",
7676
pics: ["url('orange1.jpg')", "url('orange2.jpg')", "url('orange3.jpg')", "url('orange4.jpg')"],
77-
key: "Digit3"
77+
key: "KeyO"
7878
}
7979
]
80+
var soundUrl = "https://freesound.org/people/LittleRainySeasons/sounds/335908/download/335908__littlerainyseasons__correct.mp3";
81+
var badSound = "https://freesound.org/people/RICHERlandTV/sounds/216090/download/216090__richerlandtv__bad-beep-incorrect.mp3";
8082
var out = []; // Initialise array of names of fruits
8183
var mappings = {};
8284
var options = {
8385
id: 'my-id',
8486
target: document.getElementById('tehbody')
8587
};
86-
88+
function playSound(soundfile) { // This will play an mp3
89+
var snd = new Audio(soundfile);
90+
snd.play()
91+
}
8792
var nanobar = new Nanobar( options );
8893
var b = 0;
8994
var meee = setInterval(function () {
@@ -188,12 +193,14 @@ <h1 class="win2" style="display: none"></h1> <!--// Cre
188193
var key2 = choose(out) // ^
189194
correct++; // Add 1 to the win counter
190195
$("#scorecount").text(correct - incorrect)
196+
playSound(soundUrl);
191197
if ((correct - incorrect) >= 40 && (correct - incorrect) <= 42) {
192198
initPic("url('legendary.png')", key)
193199
} else {
194200
initPic(getImageFromName(key2), key) // And set the background and text to those random fruits
195201
}
196202
} else {
203+
playSound(badSound)
197204
incorrect = incorrect + 1; // If the fruit is wrong, add one to the incorrect score
198205
$("#scorecount").text(correct - incorrect) // And update visual counter
199206
}

screenshots/game/end.png

49.1 KB
Loading
3.07 MB
Loading

storage/leaderboard.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[{"name":"Dankest guy in town","score":42036069420}]
1+
[{"name":"Dankest guy in town","score":42036069420},{"name":"sareh","score":28},{"name":"JayWilliams","score":5}]

0 commit comments

Comments
 (0)