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