say game over
This commit is contained in:
1
app.js
1
app.js
@@ -138,6 +138,7 @@ let game = {
|
|||||||
scene.music.pause()
|
scene.music.pause()
|
||||||
stats.clock.stop()
|
stats.clock.stop()
|
||||||
messagesSpan.addNewChild("div", { className: "show-level-animation", innerHTML: `<h1>GAME<br/>OVER</h1>` })
|
messagesSpan.addNewChild("div", { className: "show-level-animation", innerHTML: `<h1>GAME<br/>OVER</h1>` })
|
||||||
|
stats.speak("Game Over")
|
||||||
|
|
||||||
menu.pauseButton.hide()
|
menu.pauseButton.hide()
|
||||||
menu.startButton.name("Rejouer")
|
menu.startButton.name("Rejouer")
|
||||||
|
|||||||
24
jsm/Stats.js
24
jsm/Stats.js
@@ -34,6 +34,7 @@ class Stats {
|
|||||||
timeZone: "UTC"
|
timeZone: "UTC"
|
||||||
})
|
})
|
||||||
this.elapsedTime = 0
|
this.elapsedTime = 0
|
||||||
|
this.speechSynthesisAvailable = 'speechSynthesis' in window;
|
||||||
|
|
||||||
this.init()
|
this.init()
|
||||||
}
|
}
|
||||||
@@ -71,7 +72,7 @@ class Stats {
|
|||||||
if (level <= 20) this.fallPeriod = 1000 * Math.pow(0.8 - ((level - 1) * 0.007), level - 1)
|
if (level <= 20) this.fallPeriod = 1000 * Math.pow(0.8 - ((level - 1) * 0.007), level - 1)
|
||||||
if (level > 15) this.lockDelay = 500 * Math.pow(0.9, level - 15)
|
if (level > 15) this.lockDelay = 500 * Math.pow(0.9, level - 15)
|
||||||
messagesSpan.addNewChild("div", { className: "show-level-animation", innerHTML: `<h1>NIVEAU<br/>${this.level}</h1>` })
|
messagesSpan.addNewChild("div", { className: "show-level-animation", innerHTML: `<h1>NIVEAU<br/>${this.level}</h1>` })
|
||||||
speak(`Niveau ${level}`, this.settings.sfxVolume);
|
this.speak(`Niveau ${level}`, this.settings.sfxVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
get level() {
|
get level() {
|
||||||
@@ -180,24 +181,23 @@ class Stats {
|
|||||||
this.b2b = -1
|
this.b2b = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
if (speechSynthesisAvailable && this.settings.sfxVolume) {
|
if (this.speechSynthesisAvailable && this.settings.sfxVolume) {
|
||||||
if (tSpin) speak(tSpin, this.settings.sfxVolume);
|
if (tSpin) this.speak(tSpin, this.settings.sfxVolume);
|
||||||
if (nbClearedLines) speak(CLEARED_LINES_NAMES[nbClearedLines], this.settings.sfxVolume);
|
if (nbClearedLines) this.speak(CLEARED_LINES_NAMES[nbClearedLines], this.settings.sfxVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.goal -= awardedLineClears
|
this.goal -= awardedLineClears
|
||||||
if (this.goal <= 0) return this.level++
|
if (this.goal <= 0) return this.level++
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
speak(text, volume=1) {
|
||||||
|
if (!this.speechSynthesisAvailable) return;
|
||||||
|
|
||||||
const speechSynthesisAvailable = 'speechSynthesis' in window;
|
const utterance = new SpeechSynthesisUtterance(text);
|
||||||
function speak(text, volume=1) {
|
utterance.lang = 'fr-FR';
|
||||||
if (!speechSynthesisAvailable) return;
|
utterance.volume = volume;
|
||||||
const utterance = new SpeechSynthesisUtterance(text);
|
speechSynthesis.speak(utterance);
|
||||||
utterance.lang = 'fr-FR';
|
}
|
||||||
utterance.volume = volume;
|
|
||||||
speechSynthesis.speak(utterance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -164,8 +164,8 @@ InstancedMino.prototype.materials = {
|
|||||||
envMap: environment,
|
envMap: environment,
|
||||||
side: THREE.DoubleSide,
|
side: THREE.DoubleSide,
|
||||||
transparent: true,
|
transparent: true,
|
||||||
opacity: 0.5,
|
opacity: 0.55,
|
||||||
roughness: 0.25,
|
roughness: 0.35,
|
||||||
metalness: 0.9,
|
metalness: 0.9,
|
||||||
}),
|
}),
|
||||||
Espace: new THREE.MeshStandardMaterial({
|
Espace: new THREE.MeshStandardMaterial({
|
||||||
|
|||||||
Reference in New Issue
Block a user