diff --git a/index.html b/index.html index acd1937..abccf9c 100644 --- a/index.html +++ b/index.html @@ -247,11 +247,58 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/js/app.js b/js/app.js index 6e38ede..4670bae 100644 --- a/js/app.js +++ b/js/app.js @@ -32,6 +32,7 @@ function pauseSettings() { document.onkeydown = null; settings.show(); + playSound(menuhover) } function newGame(event) { @@ -82,6 +83,8 @@ function resume(event) { if (matrix.piece) scheduler.setInterval(fall, stats.fallPeriod); else generate(); + + playSound(menuconfirm) } } @@ -103,19 +106,19 @@ function generate(piece) { } let playerActions = { - moveLeft: () => matrix.piece.move(TRANSLATION.LEFT), + moveLeft: () => matrix.piece.move(TRANSLATION.LEFT)? playSound(move) : playSound(hit), - moveRight: () => matrix.piece.move(TRANSLATION.RIGHT), + moveRight: () => matrix.piece.move(TRANSLATION.RIGHT)? playSound(move) : playSound(hit), - rotateClockwise: () => matrix.piece.rotate(ROTATION.CW), + rotateClockwise: () => matrix.piece.rotate(ROTATION.CW)? playSound(rotate) : playSound(hit), - rotateCounterclockwise: () => matrix.piece.rotate(ROTATION.CCW), + rotateCounterclockwise: () => matrix.piece.rotate(ROTATION.CCW)? playSound(rotate) : playSound(hit), - softDrop: () => matrix.piece.move(TRANSLATION.DOWN) && ++stats.score, + softDrop: () => (matrix.piece.move(TRANSLATION.DOWN) && ++stats.score)? playSound(move) : playSound(floor), hardDrop: function () { scheduler.clearTimeout(lockDown); - playSound(hardDropSound); + playSound(harddrop); while (matrix.piece.move(TRANSLATION.DOWN, ROTATION.NONE, true)) stats.score += 2; matrixCard.classList.remove('hard-dropped-table-animation'); matrixCard.offsetHeight; @@ -128,6 +131,7 @@ let playerActions = { if (matrix.piece.holdEnabled) { scheduler.clearInterval(fall); scheduler.clearTimeout(lockDown); + playSound(hold) let piece = matrix.piece; piece.facing = FACING.NORTH; diff --git a/js/game_logic.js b/js/game_logic.js index 682318d..d5406fe 100644 --- a/js/game_logic.js +++ b/js/game_logic.js @@ -17,7 +17,7 @@ const T_SPIN = { T_SPIN: "PIROUETTE" } -// score = AWARDED_LINE_CLEARS[tSpin][nbClearedLines] +// score = AWARDED_LINE_CLEARS[tSpin][clearedLines] const AWARDED_LINE_CLEARS = { [T_SPIN.NONE]: [0, 1, 3, 5, 8], [T_SPIN.MINI]: [1, 2], @@ -282,18 +282,18 @@ class Matrix extends MinoesTable { } clearLines() { - let nbClearedLines = 0 + let clearedLines = 0 for (let y=0; y lockedMino).length == this.columns) { - nbClearedLines++ + clearedLines++ this.blocks.splice(y, 1) this.blocks.unshift(Array(matrix.columns)) this.table.rows[y].classList.add("cleared-line-animation") } } this.redraw() - return nbClearedLines + return clearedLines } } Matrix.prototype.init_center = [4, 4] diff --git a/js/interface.js b/js/interface.js index 986d562..56dcac0 100644 --- a/js/interface.js +++ b/js/interface.js @@ -144,8 +144,8 @@ class Stats { levelInput.value = localStorage['startLevel'] || 1; this.score = 0; this.goal = 0; - this.combo = 0; - this.b2b = 0; + this.combo = -1; + this.b2b = -1; this.startTime = new Date(); this.lockDelay = DELAY.LOCK; this.totalClearedLines = 0; @@ -231,23 +231,23 @@ class Stats { return new Date() - this.startTime; } - lockDown(tSpin, nbClearedLines) { - this.totalClearedLines += nbClearedLines; - if (nbClearedLines == 4) this.nbQuatuors++; + lockDown(tSpin, clearedLines) { + this.totalClearedLines += clearedLines; + if (clearedLines == 4) this.nbQuatuors++; if (tSpin == T_SPIN.T_SPIN) this.nbTSpin++; // Cleared lines & T-Spin - let awardedLineClears = AWARDED_LINE_CLEARS[tSpin][nbClearedLines]; + let awardedLineClears = AWARDED_LINE_CLEARS[tSpin][clearedLines]; let patternScore = 100 * this.level * awardedLineClears; if (tSpin) messagesSpan.addNewChild('div', { className: 'rotate-in-animation', innerHTML: tSpin, }); - if (nbClearedLines) + if (clearedLines) messagesSpan.addNewChild('div', { className: 'zoom-in-animation', - innerHTML: CLEARED_LINES_NAMES[nbClearedLines], + innerHTML: CLEARED_LINES_NAMES[clearedLines], }); if (patternScore) { messagesSpan.addNewChild('div', { @@ -259,10 +259,10 @@ class Stats { } // Combo - if (nbClearedLines) { + if (clearedLines) { this.combo++; if (this.combo >= 1) { - let comboScore = (nbClearedLines == 1 ? 20 : 50) * this.combo * this.level; + let comboScore = (clearedLines == 1 ? 20 : 50) * this.combo * this.level; if (this.combo == 1) { messagesSpan.addNewChild('div', { className: 'zoom-in-animation', @@ -279,11 +279,12 @@ class Stats { this.score += comboScore; } } else { + if (this.combo >= 1) playSound(combobreak) this.combo = -1; } // Back to back sequence - if (nbClearedLines == 4 || (tSpin && nbClearedLines)) { + if (clearedLines == 4 || (tSpin && clearedLines)) { this.b2b++; if (this.b2b >= 1) { let b2bScore = patternScore / 2; @@ -302,23 +303,64 @@ class Stats { } this.score += b2bScore; } - } else if (nbClearedLines && !tSpin) { + } else if (clearedLines && !tSpin) { if (this.b2b >= 1) { messagesSpan.addNewChild('div', { className: 'zoom-in-animation', style: 'animation-delay: .4s', innerHTML: `FIN DU BOUT À BOUT`, }); + playSound(btb_break) } this.b2b = -1; } - // Sound - if (sfxVolumeRange.value) { - if (nbClearedLines == 4) playSound(quatuorSound, this.combo); - else if (nbClearedLines) playSound(lineClearSound, this.combo); - if (tSpin) playSound(tSpinSound, this.combo); - } + // Sounds + if (clearedLines == 4 || (tSpin && clearedLines)) { + if (this.b2b >= 1) switch(this.b2b) { + case 1: playSound(btb_1); break + case 2: playSound(btb_2); break + default: playSound(btb_3) + } else if (this.combo >= 1) switch(this.combo) { + case 1: playSound(combo_1_power); break + case 2: playSound(combo_2_power); break + case 3: playSound(combo_3_power); break + case 4: playSound(combo_4_power); break + case 5: playSound(combo_5_power); break + case 6: playSound(combo_6_power); break + case 7: playSound(combo_7_power); break + case 8: playSound(combo_8_power); break + case 9: playSound(combo_9_power); break + case 10: playSound(combo_10_power); break + case 11: playSound(combo_11_power); break + case 12: playSound(combo_12_power); break + case 13: playSound(combo_13_power); break + case 14: playSound(combo_14_power); break + case 15: playSound(combo_15_power); break + default: playSound(combo_16_power) + } else if (clearedLines == 4) playSound(clearbtb); + else playSound(clearspin); + } else if (this.combo >= 1) switch(this.combo) { + case 1: playSound(combo_1); break + case 2: playSound(combo_2); break + case 3: playSound(combo_3); break + case 4: playSound(combo_4); break + case 5: playSound(combo_5); break + case 6: playSound(combo_6); break + case 7: playSound(combo_7); break + case 8: playSound(combo_8); break + case 9: playSound(combo_9); break + case 10: playSound(combo_10); break + case 11: playSound(combo_11); break + case 12: playSound(combo_12); break + case 13: playSound(combo_13); break + case 14: playSound(combo_14); break + case 15: playSound(combo_15); break + default: playSound(combo_16) + } else if (tSpin) { + if (clearedLines) playSound(clearspin); + else playSound(spin); + } else if (clearedLines) playSound(clearline); this.goal -= awardedLineClears; if (this.goal <= 0) this.level++; diff --git a/snd/allclear.ogg b/snd/allclear.ogg new file mode 100644 index 0000000..48c76b3 Binary files /dev/null and b/snd/allclear.ogg differ diff --git a/snd/btb_1.ogg b/snd/btb_1.ogg new file mode 100644 index 0000000..2c3d1a0 Binary files /dev/null and b/snd/btb_1.ogg differ diff --git a/snd/btb_2.ogg b/snd/btb_2.ogg new file mode 100644 index 0000000..2b4090c Binary files /dev/null and b/snd/btb_2.ogg differ diff --git a/snd/btb_3.ogg b/snd/btb_3.ogg new file mode 100644 index 0000000..f196f3d Binary files /dev/null and b/snd/btb_3.ogg differ diff --git a/snd/btb_break.ogg b/snd/btb_break.ogg new file mode 100644 index 0000000..dad3fa2 Binary files /dev/null and b/snd/btb_break.ogg differ diff --git a/snd/clearbtb.ogg b/snd/clearbtb.ogg new file mode 100644 index 0000000..255bbfb Binary files /dev/null and b/snd/clearbtb.ogg differ diff --git a/snd/clearline.ogg b/snd/clearline.ogg new file mode 100644 index 0000000..f740eda Binary files /dev/null and b/snd/clearline.ogg differ diff --git a/snd/clearquad.ogg b/snd/clearquad.ogg new file mode 100644 index 0000000..169d76a Binary files /dev/null and b/snd/clearquad.ogg differ diff --git a/snd/clearspin.ogg b/snd/clearspin.ogg new file mode 100644 index 0000000..3701cbe Binary files /dev/null and b/snd/clearspin.ogg differ diff --git a/snd/clutch.mp3 b/snd/clutch.mp3 new file mode 100644 index 0000000..5e80c4a Binary files /dev/null and b/snd/clutch.mp3 differ diff --git a/snd/combo_1.mp3 b/snd/combo_1.mp3 new file mode 100644 index 0000000..91c1491 Binary files /dev/null and b/snd/combo_1.mp3 differ diff --git a/snd/combo_10.mp3 b/snd/combo_10.mp3 new file mode 100644 index 0000000..d00c754 Binary files /dev/null and b/snd/combo_10.mp3 differ diff --git a/snd/combo_10_power.mp3 b/snd/combo_10_power.mp3 new file mode 100644 index 0000000..d84bc7f Binary files /dev/null and b/snd/combo_10_power.mp3 differ diff --git a/snd/combo_11.mp3 b/snd/combo_11.mp3 new file mode 100644 index 0000000..4369b4d Binary files /dev/null and b/snd/combo_11.mp3 differ diff --git a/snd/combo_11_power.mp3 b/snd/combo_11_power.mp3 new file mode 100644 index 0000000..7bbccdd Binary files /dev/null and b/snd/combo_11_power.mp3 differ diff --git a/snd/combo_12.mp3 b/snd/combo_12.mp3 new file mode 100644 index 0000000..a349839 Binary files /dev/null and b/snd/combo_12.mp3 differ diff --git a/snd/combo_12_power.mp3 b/snd/combo_12_power.mp3 new file mode 100644 index 0000000..43de2d7 Binary files /dev/null and b/snd/combo_12_power.mp3 differ diff --git a/snd/combo_13.mp3 b/snd/combo_13.mp3 new file mode 100644 index 0000000..9591644 Binary files /dev/null and b/snd/combo_13.mp3 differ diff --git a/snd/combo_13_power.mp3 b/snd/combo_13_power.mp3 new file mode 100644 index 0000000..6dae7c9 Binary files /dev/null and b/snd/combo_13_power.mp3 differ diff --git a/snd/combo_14.mp3 b/snd/combo_14.mp3 new file mode 100644 index 0000000..aae4f2d Binary files /dev/null and b/snd/combo_14.mp3 differ diff --git a/snd/combo_14_power.mp3 b/snd/combo_14_power.mp3 new file mode 100644 index 0000000..74d465b Binary files /dev/null and b/snd/combo_14_power.mp3 differ diff --git a/snd/combo_15.mp3 b/snd/combo_15.mp3 new file mode 100644 index 0000000..812a79b Binary files /dev/null and b/snd/combo_15.mp3 differ diff --git a/snd/combo_15_power.mp3 b/snd/combo_15_power.mp3 new file mode 100644 index 0000000..cecf380 Binary files /dev/null and b/snd/combo_15_power.mp3 differ diff --git a/snd/combo_16.ogg b/snd/combo_16.ogg new file mode 100644 index 0000000..8a49a06 Binary files /dev/null and b/snd/combo_16.ogg differ diff --git a/snd/combo_16_power.ogg b/snd/combo_16_power.ogg new file mode 100644 index 0000000..73fc7b8 Binary files /dev/null and b/snd/combo_16_power.ogg differ diff --git a/snd/combo_1_power.mp3 b/snd/combo_1_power.mp3 new file mode 100644 index 0000000..7c1751d Binary files /dev/null and b/snd/combo_1_power.mp3 differ diff --git a/snd/combo_2.mp3 b/snd/combo_2.mp3 new file mode 100644 index 0000000..0bdfb0f Binary files /dev/null and b/snd/combo_2.mp3 differ diff --git a/snd/combo_2_power.mp3 b/snd/combo_2_power.mp3 new file mode 100644 index 0000000..088f432 Binary files /dev/null and b/snd/combo_2_power.mp3 differ diff --git a/snd/combo_3.mp3 b/snd/combo_3.mp3 new file mode 100644 index 0000000..6a31f37 Binary files /dev/null and b/snd/combo_3.mp3 differ diff --git a/snd/combo_3_power.mp3 b/snd/combo_3_power.mp3 new file mode 100644 index 0000000..475f1a3 Binary files /dev/null and b/snd/combo_3_power.mp3 differ diff --git a/snd/combo_4.mp3 b/snd/combo_4.mp3 new file mode 100644 index 0000000..e6ae300 Binary files /dev/null and b/snd/combo_4.mp3 differ diff --git a/snd/combo_4_power.mp3 b/snd/combo_4_power.mp3 new file mode 100644 index 0000000..6f653de Binary files /dev/null and b/snd/combo_4_power.mp3 differ diff --git a/snd/combo_5.mp3 b/snd/combo_5.mp3 new file mode 100644 index 0000000..4ea3ce9 Binary files /dev/null and b/snd/combo_5.mp3 differ diff --git a/snd/combo_5_power.mp3 b/snd/combo_5_power.mp3 new file mode 100644 index 0000000..c45b240 Binary files /dev/null and b/snd/combo_5_power.mp3 differ diff --git a/snd/combo_6.mp3 b/snd/combo_6.mp3 new file mode 100644 index 0000000..1f97dc6 Binary files /dev/null and b/snd/combo_6.mp3 differ diff --git a/snd/combo_6_power.mp3 b/snd/combo_6_power.mp3 new file mode 100644 index 0000000..4cd7d23 Binary files /dev/null and b/snd/combo_6_power.mp3 differ diff --git a/snd/combo_7.mp3 b/snd/combo_7.mp3 new file mode 100644 index 0000000..7a2c0f0 Binary files /dev/null and b/snd/combo_7.mp3 differ diff --git a/snd/combo_7_power.mp3 b/snd/combo_7_power.mp3 new file mode 100644 index 0000000..62daa8b Binary files /dev/null and b/snd/combo_7_power.mp3 differ diff --git a/snd/combo_8.mp3 b/snd/combo_8.mp3 new file mode 100644 index 0000000..6e2856e Binary files /dev/null and b/snd/combo_8.mp3 differ diff --git a/snd/combo_8_power.mp3 b/snd/combo_8_power.mp3 new file mode 100644 index 0000000..af06f6b Binary files /dev/null and b/snd/combo_8_power.mp3 differ diff --git a/snd/combo_9.mp3 b/snd/combo_9.mp3 new file mode 100644 index 0000000..00bfa50 Binary files /dev/null and b/snd/combo_9.mp3 differ diff --git a/snd/combo_9_power.mp3 b/snd/combo_9_power.mp3 new file mode 100644 index 0000000..d6b23ea Binary files /dev/null and b/snd/combo_9_power.mp3 differ diff --git a/snd/combobreak.mp3 b/snd/combobreak.mp3 new file mode 100644 index 0000000..8ca487c Binary files /dev/null and b/snd/combobreak.mp3 differ diff --git a/snd/counter.ogg b/snd/counter.ogg new file mode 100644 index 0000000..d75409f Binary files /dev/null and b/snd/counter.ogg differ diff --git a/snd/damage_alert.ogg b/snd/damage_alert.ogg new file mode 100644 index 0000000..c546478 Binary files /dev/null and b/snd/damage_alert.ogg differ diff --git a/snd/damage_large.ogg b/snd/damage_large.ogg new file mode 100644 index 0000000..e0df48b Binary files /dev/null and b/snd/damage_large.ogg differ diff --git a/snd/damage_medium.ogg b/snd/damage_medium.ogg new file mode 100644 index 0000000..d16d6a7 Binary files /dev/null and b/snd/damage_medium.ogg differ diff --git a/snd/damage_small.ogg b/snd/damage_small.ogg new file mode 100644 index 0000000..0744919 Binary files /dev/null and b/snd/damage_small.ogg differ diff --git a/snd/death.mp3 b/snd/death.mp3 new file mode 100644 index 0000000..a6944c0 Binary files /dev/null and b/snd/death.mp3 differ diff --git a/snd/elim.mp3 b/snd/elim.mp3 new file mode 100644 index 0000000..4c7a328 Binary files /dev/null and b/snd/elim.mp3 differ diff --git a/snd/exchange.ogg b/snd/exchange.ogg new file mode 100644 index 0000000..aad251e Binary files /dev/null and b/snd/exchange.ogg differ diff --git a/snd/floor.ogg b/snd/floor.ogg new file mode 100644 index 0000000..2c34a2c Binary files /dev/null and b/snd/floor.ogg differ diff --git a/snd/garbage_in_large.ogg b/snd/garbage_in_large.ogg new file mode 100644 index 0000000..42013eb Binary files /dev/null and b/snd/garbage_in_large.ogg differ diff --git a/snd/garbage_in_medium.ogg b/snd/garbage_in_medium.ogg new file mode 100644 index 0000000..8f8459f Binary files /dev/null and b/snd/garbage_in_medium.ogg differ diff --git a/snd/garbage_in_small.ogg b/snd/garbage_in_small.ogg new file mode 100644 index 0000000..27a58ab Binary files /dev/null and b/snd/garbage_in_small.ogg differ diff --git a/snd/garbage_out_large.ogg b/snd/garbage_out_large.ogg new file mode 100644 index 0000000..66eaa70 Binary files /dev/null and b/snd/garbage_out_large.ogg differ diff --git a/snd/garbage_out_medium.ogg b/snd/garbage_out_medium.ogg new file mode 100644 index 0000000..85767e5 Binary files /dev/null and b/snd/garbage_out_medium.ogg differ diff --git a/snd/garbage_out_small.ogg b/snd/garbage_out_small.ogg new file mode 100644 index 0000000..dfa57f7 Binary files /dev/null and b/snd/garbage_out_small.ogg differ diff --git a/snd/garbagerise.ogg b/snd/garbagerise.ogg new file mode 100644 index 0000000..ff88f45 Binary files /dev/null and b/snd/garbagerise.ogg differ diff --git a/snd/garbagesmash.ogg b/snd/garbagesmash.ogg new file mode 100644 index 0000000..37fc134 Binary files /dev/null and b/snd/garbagesmash.ogg differ diff --git a/snd/harddrop.ogg b/snd/harddrop.ogg new file mode 100644 index 0000000..fb16625 Binary files /dev/null and b/snd/harddrop.ogg differ diff --git a/snd/hit.mp3 b/snd/hit.mp3 new file mode 100644 index 0000000..3c0c33a Binary files /dev/null and b/snd/hit.mp3 differ diff --git a/snd/hold.ogg b/snd/hold.ogg new file mode 100644 index 0000000..26c2b66 Binary files /dev/null and b/snd/hold.ogg differ diff --git a/snd/hyperalert.mp3 b/snd/hyperalert.mp3 new file mode 100644 index 0000000..3d10f20 Binary files /dev/null and b/snd/hyperalert.mp3 differ diff --git a/snd/menuconfirm.mp3 b/snd/menuconfirm.mp3 new file mode 100644 index 0000000..21f9a75 Binary files /dev/null and b/snd/menuconfirm.mp3 differ diff --git a/snd/menuhit1.mp3 b/snd/menuhit1.mp3 new file mode 100644 index 0000000..9f1f556 Binary files /dev/null and b/snd/menuhit1.mp3 differ diff --git a/snd/menuhit2.mp3 b/snd/menuhit2.mp3 new file mode 100644 index 0000000..9f1f556 Binary files /dev/null and b/snd/menuhit2.mp3 differ diff --git a/snd/menuhit3.mp3 b/snd/menuhit3.mp3 new file mode 100644 index 0000000..9f1f556 Binary files /dev/null and b/snd/menuhit3.mp3 differ diff --git a/snd/menuhover.ogg b/snd/menuhover.ogg new file mode 100644 index 0000000..d1e808e Binary files /dev/null and b/snd/menuhover.ogg differ diff --git a/snd/move.ogg b/snd/move.ogg new file mode 100644 index 0000000..308ff6d Binary files /dev/null and b/snd/move.ogg differ diff --git a/snd/offset.ogg b/snd/offset.ogg new file mode 100644 index 0000000..41469c7 Binary files /dev/null and b/snd/offset.ogg differ diff --git a/snd/rotate.ogg b/snd/rotate.ogg new file mode 100644 index 0000000..f7ec104 Binary files /dev/null and b/snd/rotate.ogg differ diff --git a/snd/shatter.mp3 b/snd/shatter.mp3 new file mode 100644 index 0000000..cfaa633 Binary files /dev/null and b/snd/shatter.mp3 differ diff --git a/snd/spin.ogg b/snd/spin.ogg new file mode 100644 index 0000000..cc7d725 Binary files /dev/null and b/snd/spin.ogg differ diff --git a/snd/spinend.mp3 b/snd/spinend.mp3 new file mode 100644 index 0000000..a89839d Binary files /dev/null and b/snd/spinend.mp3 differ diff --git a/snd/topout.ogg b/snd/topout.ogg new file mode 100644 index 0000000..b806f99 Binary files /dev/null and b/snd/topout.ogg differ diff --git a/snd/warning.ogg b/snd/warning.ogg new file mode 100644 index 0000000..e2c418b Binary files /dev/null and b/snd/warning.ogg differ diff --git a/sounds/78GUIR.wav b/sounds/78GUIR.wav deleted file mode 100644 index 50fffa0..0000000 Binary files a/sounds/78GUIR.wav and /dev/null differ diff --git a/sounds/808COW.wav b/sounds/808COW.wav deleted file mode 100644 index 0b05a5d..0000000 Binary files a/sounds/808COW.wav and /dev/null differ diff --git a/sounds/808K_A.wav b/sounds/808K_A.wav deleted file mode 100644 index 923a584..0000000 Binary files a/sounds/808K_A.wav and /dev/null differ diff --git a/sounds/909S.wav b/sounds/909S.wav deleted file mode 100644 index 1c74581..0000000 Binary files a/sounds/909S.wav and /dev/null differ diff --git a/sounds/BRRDC1.wav b/sounds/BRRDC1.wav deleted file mode 100644 index ebd22d1..0000000 Binary files a/sounds/BRRDC1.wav and /dev/null differ