change note on combo

This commit is contained in:
2023-12-06 01:07:15 +01:00
parent 365fb17694
commit 048d17e041
11 changed files with 46 additions and 44 deletions

View File

@ -45,8 +45,10 @@ function newGame(event) {
settings.form.classList.add('was-validated')
} else {
const audioContext = new AudioContext()
for(const sound of document.getElementsByTagName("audio"))
for(const sound of document.getElementsByTagName("audio")) {
sound.preservesPitch = false
audioContext.createMediaElementSource(sound).connect(audioContext.destination)
}
levelInput.name = "level"
levelInput.disabled = true

View File

@ -332,7 +332,7 @@ class Tetromino {
matrix.drawPiece()
return true
} else if (!hardDropped) {
// wallSound.play()
wallSound.play()
if (translation == TRANSLATION.DOWN) {
this.locked = true
if (!scheduler.timeoutTasks.has(lockDown))

View File

@ -176,13 +176,6 @@ class Stats {
if (nbClearedLines == 4) this.nbQuatuors++
if (tSpin == T_SPIN.T_SPIN) this.nbTSpin++
// Sound
if (sfxVolumeRange.value) {
if (nbClearedLines == 4 || (nbClearedLines && tSpin)) playSound(quatuorSound)
else if (nbClearedLines) playSound(lineClearSound)
else if (tSpin) playSound(tSpinSound)
}
// Cleared lines & T-Spin
let awardedLineClears = AWARDED_LINE_CLEARS[tSpin][nbClearedLines]
let patternScore = 100 * this.level * awardedLineClears
@ -258,6 +251,13 @@ class Stats {
this.b2b = -1
}
// Sound
if (sfxVolumeRange.value) {
if (nbClearedLines == 4 || (nbClearedLines && tSpin)) playSound(quatuorSound, this.combo)
else if (nbClearedLines) playSound(lineClearSound, this.combo)
else if (tSpin) playSound(tSpinSound)
}
this.goal -= awardedLineClears
if (this.goal <= 0) this.level++
}
@ -288,7 +288,9 @@ Stats.prototype.timeFormat = new Intl.DateTimeFormat("fr-FR", {
timeZone: "UTC"
})
function playSound(sound) {
function playSound(sound, note=0) {
sound.pause()
sound.currentTime = 0
sound.playbackRate = Math.pow(5/4, note)
sound.play()
}