|
30 | 30 | <img src="orange2.jpg" style="display:none;" alt="" /> |
31 | 31 | <img src="orange3.jpg" style="display:none;" alt="" /> |
32 | 32 | <img src="orange4.jpg" style="display:none;" alt="" /> |
33 | | - |
| 33 | + <div id="dummy" style="display: none;"></div> |
34 | 34 | <h1 id="scorecount" style="color: black; padding-left: 20px"> </h1> <!--// Create the score count display element --> |
35 | 35 | <center> |
36 | 36 | <h1 class="words" style="font-family: captcha"></h1> <!-- |
@@ -74,16 +74,21 @@ <h1 class="win2" style="display: none"></h1> <!--// Cre |
74 | 74 | { |
75 | 75 | name: "Orange", |
76 | 76 | pics: ["url('orange1.jpg')", "url('orange2.jpg')", "url('orange3.jpg')", "url('orange4.jpg')"], |
77 | | - key: "Digit3" |
| 77 | + key: "KeyO" |
78 | 78 | } |
79 | 79 | ] |
| 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"; |
80 | 82 | var out = []; // Initialise array of names of fruits |
81 | 83 | var mappings = {}; |
82 | 84 | var options = { |
83 | 85 | id: 'my-id', |
84 | 86 | target: document.getElementById('tehbody') |
85 | 87 | }; |
86 | | - |
| 88 | + function playSound(soundfile) { // This will play an mp3 |
| 89 | + var snd = new Audio(soundfile); |
| 90 | + snd.play() |
| 91 | + } |
87 | 92 | var nanobar = new Nanobar( options ); |
88 | 93 | var b = 0; |
89 | 94 | var meee = setInterval(function () { |
@@ -188,12 +193,14 @@ <h1 class="win2" style="display: none"></h1> <!--// Cre |
188 | 193 | var key2 = choose(out) // ^ |
189 | 194 | correct++; // Add 1 to the win counter |
190 | 195 | $("#scorecount").text(correct - incorrect) |
| 196 | + playSound(soundUrl); |
191 | 197 | if ((correct - incorrect) >= 40 && (correct - incorrect) <= 42) { |
192 | 198 | initPic("url('legendary.png')", key) |
193 | 199 | } else { |
194 | 200 | initPic(getImageFromName(key2), key) // And set the background and text to those random fruits |
195 | 201 | } |
196 | 202 | } else { |
| 203 | + playSound(badSound) |
197 | 204 | incorrect = incorrect + 1; // If the fruit is wrong, add one to the incorrect score |
198 | 205 | $("#scorecount").text(correct - incorrect) // And update visual counter |
199 | 206 | } |
|
0 commit comments