change sounds

This commit is contained in:
Adrien MALINGREY 2023-12-03 21:47:03 +01:00
parent 227a26880d
commit 46a0500c66
8 changed files with 28 additions and 19 deletions

31
app.js
View File

@ -314,11 +314,11 @@ class Tetromino {
return false
}
move(translation, rotation=ROTATION.NONE, clearClassName="") {
move(translation, rotation=ROTATION.NONE, hardDropped=false) {
let success = this.canMove(translation, rotation)
if (success) {
scheduler.clearTimeout(lockDown)
matrix.drawPiece(this, clearClassName)
matrix.drawPiece(this, hardDropped? "trail-animation" : "")
this.center = success.center
if (rotation) this.facing = success.facing
this.lastRotation = rotation
@ -330,8 +330,8 @@ class Tetromino {
}
matrix.drawPiece()
return true
} else {
wallSound.play()
} else if (!hardDropped) {
// wallSound.play()
if (translation == TRANSLATION.DOWN) {
this.locked = true
if (!scheduler.timeoutTasks.has(lockDown))
@ -809,10 +809,8 @@ function newGame(event) {
settings.form.classList.add('was-validated')
} else {
const audioContext = new AudioContext()
audioContext.createMediaElementSource(hardDropSound).connect(audioContext.destination)
audioContext.createMediaElementSource(tSpinSound).connect(audioContext.destination)
audioContext.createMediaElementSource(lineClearSound).connect(audioContext.destination)
audioContext.createMediaElementSource(quatuorSound).connect(audioContext.destination)
for(const sound of document.getElementsByTagName("audio"))
audioContext.createMediaElementSource(sound).connect(audioContext.destination)
levelInput.name = "level"
levelInput.disabled = true
@ -835,7 +833,8 @@ function resume(event) {
settings.form.classList.add('was-validated')
if (settings.form.checkValidity()) {
for(const sound of document.getElementsByTagName("audio")) sound.volume = sfxVolumeRange.value
for(const sound of document.getElementsByTagName("audio"))
sound.volume = sfxVolumeRange.value
settings.modal.hide()
settings.getInputs()
@ -875,12 +874,21 @@ let playerActions = {
rotateCounterclockwise: () => matrix.piece.rotate(ROTATION.CCW),
softDrop: () => {if (matrix.piece.move(TRANSLATION.DOWN)) stats.score++},
softDrop: function() {
if (matrix.piece.move(TRANSLATION.DOWN)) {
stats.score++
return true
} else {
return false
}
},
hardDrop: function() {
scheduler.clearTimeout(lockDown)
playSound(hardDropSound)
while (matrix.piece.move(TRANSLATION.DOWN, ROTATION.NONE, "trail-animation")) 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")
lockDown()
},
@ -969,7 +977,6 @@ function fall() {
function lockDown() {
scheduler.clearTimeout(lockDown)
scheduler.clearInterval(fall)
wallSound.pause()
if (matrix.lock()) {
let tSpin = matrix.piece.tSpin

View File

@ -66,7 +66,7 @@
<option>Électro</option>
<option>Rétro</option>
</select></div>
<div class="col-sm-4"><input id="sfxVolumeRange" class="form-range" type="range" min="0" max="1" step="any" value="1"></div>
<div class="col-sm-4"><input id="sfxVolumeRange" class="form-range" type="range" min="0" max="1" step="any" value="0.5"></div>
<label for="sfxVolumeRange" class="col-sm-2 col-form-label">Volume</label>
</fieldset>
<fieldset class="row g-2 mb-3 align-items-center text-center">
@ -142,7 +142,9 @@
<tr class="matrix"><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
</table>
</div>
<span id="messagesSpan"></span>
<span id="messagesSpan">
<div class="show-level-animation">Chargement...</div>
</span>
</div>
<div class="col">
@ -208,11 +210,11 @@
<img src="favicons/T-0.png"/><img src="favicons/T-1.png"/><img src="favicons/T-2.png"/><img src="favicons/T-3.png"/>
<img src="favicons/Z-0.png"/><img src="favicons/Z-1.png"/><img src="favicons/Z-2.png"/><img src="favicons/Z-3.png"/>
<audio id="wallSound" src="sound/808K_A.wav" preload="auto" type="audio/wav"></audio>
<audio id="hardDropSound" src="sound/808T_A.wav" preload="auto" type="audio/wav"></audio>
<audio id="tSpinSound" src="sound/HIGHQ_A.wav" preload="auto" type="audio/wav"></audio>
<audio id="lineClearSound" src="sound/HIGHQ_B.wav" preload="auto" type="audio/wav"></audio>
<audio id="quatuorSound" src="sound/HIGHQ_C.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/Conga Low.wav" preload="auto" type="audio/wav"></audio>
<audio id="tSpinSound" src="sounds/HIGHQ_A.wav" preload="auto" type="audio/wav"></audio>
<audio id="lineClearSound" src="sounds/HIGHQ_B.wav" preload="auto" type="audio/wav"></audio>
<audio id="quatuorSound" src="sounds/HIGHQ_C.wav" preload="auto" type="audio/wav"></audio>
</span>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ENjdO4Dr2bkBIFxQpeoTz1HIcje39Wm4jDKdf19U8gI4ddQ3GYNS7NTKfAdVQSZe" crossorigin="anonymous"></script>

Binary file not shown.

BIN
sounds/Conga Low.wav Normal file

Binary file not shown.