Compare commits
No commits in common. "8773e6588538c8040a793bb8865a331d05b8189d" and "baf6e662444f2e90da4ce723e7cbf83700249971" have entirely different histories.
8773e65885
...
baf6e66244
@ -58,7 +58,8 @@
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset class="row g-2 mb-3 align-items-center text-center">
|
<fieldset class="row g-2 mb-3 align-items-center text-center">
|
||||||
<legend class="text-start">Interface</legend>
|
<legend class="text-start">Interface</legend>
|
||||||
<label for="stylesheetSelect" class="col-2 col-form-label">Thème</label>
|
<label for="sfxVolumeRange" class="col-2 col-form-label">Volume</label>
|
||||||
|
<div class="col-4 d-flex align-items-baseline"><input id="sfxVolumeRange" class="form-range" type="range" min="0" max="1" step="any" value="0.7"></div>
|
||||||
<div class="col-4"><select name="stylesheet" id="stylesheetSelect" class="form-select" oninput="document.selectedStyleSheetSet=this.value">
|
<div class="col-4"><select name="stylesheet" id="stylesheetSelect" class="form-select" oninput="document.selectedStyleSheetSet=this.value">
|
||||||
<option selected>Classique</option>
|
<option selected>Classique</option>
|
||||||
<option>Minimal</option>
|
<option>Minimal</option>
|
||||||
@ -66,8 +67,7 @@
|
|||||||
<option>Électro</option>
|
<option>Électro</option>
|
||||||
<option>Rétro</option>
|
<option>Rétro</option>
|
||||||
</select></div>
|
</select></div>
|
||||||
<div class="col-4 d-flex align-items-baseline"><input id="sfxVolumeRange" class="form-range" type="range" min="0" max="1" step="any" value="0.7"></div>
|
<label for="stylesheetSelect" class="col-2 col-form-label">Thème</label>
|
||||||
<label for="sfxVolumeRange" class="col-2 col-form-label">Volume</label>
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset class="row g-2 mb-3 align-items-center text-center">
|
<fieldset class="row g-2 mb-3 align-items-center text-center">
|
||||||
<legend class="text-start">Partie</legend>
|
<legend class="text-start">Partie</legend>
|
||||||
@ -213,7 +213,7 @@
|
|||||||
<audio id="wallSound" src="sounds/808K_A.wav" preload="auto" type="audio/wav"></audio>
|
<audio id="wallSound" src="sounds/808K_A.wav" preload="auto" type="audio/wav"></audio>
|
||||||
<audio id="hardDropSound" src="sounds/909S.wav" preload="auto" type="audio/wav"></audio>
|
<audio id="hardDropSound" src="sounds/909S.wav" preload="auto" type="audio/wav"></audio>
|
||||||
<audio id="lineClearSound" src="sounds/808COW.wav" preload="auto" type="audio/wav"></audio>
|
<audio id="lineClearSound" src="sounds/808COW.wav" preload="auto" type="audio/wav"></audio>
|
||||||
<audio id="tSpinSound" src="sounds/78GUIR.wav" preload="auto" type="audio/wav"></audio>
|
<audio id="tSpinSound" src="sounds/909CHH.wav" preload="auto" type="audio/wav"></audio>
|
||||||
<audio id="quatuorSound" src="sounds/BRRDC1.wav" preload="auto" type="audio/wav"></audio>
|
<audio id="quatuorSound" src="sounds/BRRDC1.wav" preload="auto" type="audio/wav"></audio>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
45
js/app.js
45
js/app.js
@ -1,11 +1,10 @@
|
|||||||
let scheduler = new Scheduler()
|
let scheduler = new Scheduler()
|
||||||
let settings = new Settings()
|
let settings = new Settings()
|
||||||
let stats = new Stats()
|
let stats = new Stats()
|
||||||
let holdQueue = new MinoesTable("holdTable")
|
let holdQueue = new MinoesTable("holdTable")
|
||||||
let matrix = new Matrix()
|
let matrix = new Matrix()
|
||||||
let nextQueue = new NextQueue()
|
let nextQueue = new NextQueue()
|
||||||
let playing = false
|
let playing = false
|
||||||
let lastActionSucceded = true
|
|
||||||
let favicon
|
let favicon
|
||||||
|
|
||||||
window.onload = function(event) {
|
window.onload = function(event) {
|
||||||
@ -95,7 +94,6 @@ function ticktack() {
|
|||||||
|
|
||||||
function generate(piece) {
|
function generate(piece) {
|
||||||
matrix.piece = piece || nextQueue.shift()
|
matrix.piece = piece || nextQueue.shift()
|
||||||
lastActionSucceded = true
|
|
||||||
favicon.href = matrix.piece.favicon_href
|
favicon.href = matrix.piece.favicon_href
|
||||||
|
|
||||||
if (matrix.piece.canMove(TRANSLATION.NONE)) {
|
if (matrix.piece.canMove(TRANSLATION.NONE)) {
|
||||||
@ -114,15 +112,23 @@ let playerActions = {
|
|||||||
|
|
||||||
rotateCounterclockwise: () => matrix.piece.rotate(ROTATION.CCW),
|
rotateCounterclockwise: () => matrix.piece.rotate(ROTATION.CCW),
|
||||||
|
|
||||||
softDrop: () => matrix.piece.move(TRANSLATION.DOWN) && ++stats.score,
|
softDrop: function() {
|
||||||
|
if (matrix.piece.move(TRANSLATION.DOWN)) {
|
||||||
|
stats.score++
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
hardDrop: function() {
|
hardDrop: function() {
|
||||||
scheduler.clearTimeout(lockDown)
|
scheduler.clearTimeout(lockDown)
|
||||||
playSound(hardDropSound)
|
playSound(hardDropSound)
|
||||||
while (matrix.piece.move(TRANSLATION.DOWN, ROTATION.NONE, true)) stats.score +=2
|
while (matrix.piece.move(TRANSLATION.DOWN, ROTATION.NONE, true)) stats.score +=2
|
||||||
|
// wallSound.currentTime = 0
|
||||||
|
// wallSound.pause()
|
||||||
matrix.table.classList.add("hard-dropped-table-animation")
|
matrix.table.classList.add("hard-dropped-table-animation")
|
||||||
lockDown()
|
lockDown()
|
||||||
return true
|
|
||||||
},
|
},
|
||||||
|
|
||||||
hold: function() {
|
hold: function() {
|
||||||
@ -158,12 +164,7 @@ function onkeydown(event) {
|
|||||||
if (!pressedKeys.has(event.key)) {
|
if (!pressedKeys.has(event.key)) {
|
||||||
pressedKeys.add(event.key)
|
pressedKeys.add(event.key)
|
||||||
action = settings.keyBind[event.key]
|
action = settings.keyBind[event.key]
|
||||||
if (action()) {
|
action()
|
||||||
lastActionSucceded = true
|
|
||||||
} else if (lastActionSucceded) {
|
|
||||||
wallSound.play()
|
|
||||||
lastActionSucceded = false
|
|
||||||
}
|
|
||||||
if (REPEATABLE_ACTIONS.includes(action)) {
|
if (REPEATABLE_ACTIONS.includes(action)) {
|
||||||
actionsQueue.unshift(action)
|
actionsQueue.unshift(action)
|
||||||
scheduler.clearTimeout(repeat)
|
scheduler.clearTimeout(repeat)
|
||||||
@ -185,14 +186,10 @@ function repeat() {
|
|||||||
|
|
||||||
function autorepeat() {
|
function autorepeat() {
|
||||||
if (actionsQueue.length) {
|
if (actionsQueue.length) {
|
||||||
if (actionsQueue[0]()) {
|
actionsQueue[0]()
|
||||||
lastActionSucceded = true
|
} else {
|
||||||
} else if (lastActionSucceded) {
|
scheduler.clearInterval(autorepeat)
|
||||||
wallSound.play()
|
|
||||||
lastActionSucceded = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else scheduler.clearInterval(autorepeat)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onkeyup(event) {
|
function onkeyup(event) {
|
||||||
|
@ -103,32 +103,17 @@ class Scheduler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setInterval(func, delay, ...args) {
|
setInterval(func, delay, ...args) {
|
||||||
if (this.intervalTasks.has(func)) {
|
this.intervalTasks.set(func, window.setInterval(func, delay, ...args))
|
||||||
console.warn(`$func already in intervalTasks`)
|
|
||||||
return false
|
|
||||||
} else {
|
|
||||||
this.intervalTasks.set(func, window.setInterval(func, delay, ...args))
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(func, delay, ...args) {
|
setTimeout(func, delay, ...args) {
|
||||||
if (this.timeoutTasks.has(func)) {
|
this.timeoutTasks.set(func, window.setTimeout(func, delay, ...args))
|
||||||
console.warn(`$func already in timeoutTasks`)
|
|
||||||
return false
|
|
||||||
} else {
|
|
||||||
this.timeoutTasks.set(func, window.setTimeout(func, delay, ...args))
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
clearInterval(func) {
|
clearInterval(func) {
|
||||||
if (this.intervalTasks.has(func)) {
|
if (this.intervalTasks.has(func)) {
|
||||||
window.clearInterval(this.intervalTasks.get(func))
|
window.clearInterval(this.intervalTasks.get(func))
|
||||||
this.intervalTasks.delete(func)
|
this.intervalTasks.delete(func)
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,9 +121,6 @@ class Scheduler {
|
|||||||
if (this.timeoutTasks.has(func)) {
|
if (this.timeoutTasks.has(func)) {
|
||||||
window.clearTimeout(this.timeoutTasks.get(func))
|
window.clearTimeout(this.timeoutTasks.get(func))
|
||||||
this.timeoutTasks.delete(func)
|
this.timeoutTasks.delete(func)
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -350,6 +332,7 @@ class Tetromino {
|
|||||||
matrix.drawPiece()
|
matrix.drawPiece()
|
||||||
return true
|
return true
|
||||||
} else if (!hardDropped) {
|
} else if (!hardDropped) {
|
||||||
|
wallSound.play()
|
||||||
if (translation == TRANSLATION.DOWN) {
|
if (translation == TRANSLATION.DOWN) {
|
||||||
this.locked = true
|
this.locked = true
|
||||||
if (!scheduler.timeoutTasks.has(lockDown))
|
if (!scheduler.timeoutTasks.has(lockDown))
|
||||||
|
Binary file not shown.
BIN
sounds/909CHH.wav
Normal file
BIN
sounds/909CHH.wav
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user