sounds
This commit is contained in:
parent
d1aae20532
commit
0821509986
Binary file not shown.
|
@ -63,5 +63,11 @@
|
||||||
<div id="timer">
|
<div id="timer">
|
||||||
10
|
10
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div style="display: none">
|
||||||
|
<audio src="richtig.ogg" id="audio_right">
|
||||||
|
<audio src="falsch.ogg" id="audio_wrong">
|
||||||
|
<audio src="timeout.ogg" id="audio_timeout">
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
16
quiz.js
16
quiz.js
|
@ -337,7 +337,7 @@ function switchToGame() {
|
||||||
liEl.fadeTo(0, 1);
|
liEl.fadeTo(0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
var switchToAnswer = function() {
|
var switchToAnswer = function(isTimeout) {
|
||||||
if (activePlayer !== null) {
|
if (activePlayer !== null) {
|
||||||
// player confirmed answer or gave up
|
// player confirmed answer or gave up
|
||||||
var answerEl;
|
var answerEl;
|
||||||
|
@ -348,12 +348,16 @@ function switchToGame() {
|
||||||
var isRight = choice !== null && q.answers[choice].right === true;
|
var isRight = choice !== null && q.answers[choice].right === true;
|
||||||
if (isRight) {
|
if (isRight) {
|
||||||
playerScores[activePlayer] += q.tier;
|
playerScores[activePlayer] += q.tier;
|
||||||
|
|
||||||
|
$('#audio_right')[0].play();
|
||||||
} else {
|
} else {
|
||||||
playerScores[activePlayer] -= q.tier;
|
playerScores[activePlayer] -= q.tier;
|
||||||
|
|
||||||
if (choice !== null)
|
if (choice !== null)
|
||||||
// Hilight the wrong choice
|
// Hilight the wrong choice
|
||||||
answerEl.addClass('wrong');
|
answerEl.addClass('wrong');
|
||||||
|
if (!isTimeout)
|
||||||
|
$('#audio_wrong')[0].play();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -363,6 +367,8 @@ function switchToGame() {
|
||||||
playerScores[i] -= q.tier;
|
playerScores[i] -= q.tier;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!isTimeout)
|
||||||
|
$('#audio_wrong')[0].play();
|
||||||
}
|
}
|
||||||
updateScores();
|
updateScores();
|
||||||
timer.halt();
|
timer.halt();
|
||||||
|
@ -387,7 +393,11 @@ function switchToGame() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
timer.set(TIMER_QUESTION, switchToAnswer);
|
var timeout = function() {
|
||||||
|
$('#audio_timeout')[0].play();
|
||||||
|
switchToAnswer(true);
|
||||||
|
};
|
||||||
|
timer.set(TIMER_QUESTION, timeout);
|
||||||
|
|
||||||
keyHandler = function(key, keyCode) {
|
keyHandler = function(key, keyCode) {
|
||||||
if (keyCode === 27) {
|
if (keyCode === 27) {
|
||||||
|
@ -401,7 +411,7 @@ function switchToGame() {
|
||||||
if (playerNames[player]) {
|
if (playerNames[player]) {
|
||||||
activePlayer = player;
|
activePlayer = player;
|
||||||
updateTier();
|
updateTier();
|
||||||
timer.set(TIMER_ANSWER, switchToAnswer);
|
timer.set(TIMER_ANSWER, timeout);
|
||||||
}
|
}
|
||||||
} else if (activePlayer !== null &&
|
} else if (activePlayer !== null &&
|
||||||
"1234".indexOf(key) >= 0) {
|
"1234".indexOf(key) >= 0) {
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue