Cleaning Coin

This commit is contained in:
Thomas FORGIONE 2015-10-02 15:21:29 +02:00
parent 0e3eae5ff1
commit f17ea91581
3 changed files with 40 additions and 48 deletions

View File

@ -230,7 +230,9 @@ Coin.prototype.update = function() {
};
Coin.prototype.get = function() {
if (!this.got) {
if (this.got) {
return;
}
this.got = true;
if (typeof Coin.onCoinGot === 'function') {
@ -245,10 +247,9 @@ Coin.prototype.get = function() {
this.mesh.material.opacity = 1;
Coin.sounds[Coin.total ++].play();
if (Coin.total === 8) {
if (typeof Coin.onLastCoin === 'function') {
Coin.onLastCoin();
}
if (Coin.total === Coin.max) {
// You got the last coin
var music = document.getElementById('music');
if (music !== null) {
@ -266,7 +267,6 @@ Coin.prototype.get = function() {
}
Coin.set();
}
};
Coin.lastSound = new Audio('/static/data/music/starappears' + Coin.extension);

View File

@ -44,11 +44,11 @@ var nextPage = '/prototype/play';
Coin.onCoinGot = function(coin) {
if (coin === 6) {
setTimeout(function() { setNextButton(nextPage); }, 60*1000);
} else if (coin === 8) {
setNextButton(nextPage);
}
};
Coin.onLastCoin = function() { setNextButton(nextPage); };
function main() {
// Main container that holds everything

View File

@ -23,11 +23,11 @@ var nextPage = '/before-begin';
Coin.onCoinGot = function(val) {
if (val === 6) {
setTimeout(function() {setNextButton(nextPage); }, 60*1000);
} else if (val === 8) {
setNextButton(nextPage);
}
};
Coin.onLastCoin = function() { setNextButton(nextPage); };
window.onbeforeunload = function() {
if (!($('#next').is(":visible"))) {
@ -82,14 +82,6 @@ function main() {
// Log fps
setInterval(function() {logfps(stats.getFps());}, 500);
Coin.onLastCoin = function() {
Coin.blink();
$('#next').click(function() {
window.location = '/before-begin';
});
$('#next').show();
};
}
function initThreeElements() {