move sounds
This commit is contained in:
17
app.js
17
app.js
@@ -175,16 +175,23 @@ function playSound(sound, note=0) {
|
|||||||
/* Handle player inputs */
|
/* Handle player inputs */
|
||||||
|
|
||||||
let playerActions = {
|
let playerActions = {
|
||||||
moveLeft: () => scene.playfield.piece.move(TRANSLATION.LEFT),
|
moveLeft: () => scene.playfield.piece.move(TRANSLATION.LEFT)? scene.moveSound.play() : scene.hitSound.stop() && scene.hitSound.play(),
|
||||||
|
|
||||||
moveRight: () => scene.playfield.piece.move(TRANSLATION.RIGHT),
|
moveRight: () => scene.playfield.piece.move(TRANSLATION.RIGHT)? scene.moveSound.play() : scene.hitSound.stop() && scene.hitSound.play(),
|
||||||
|
|
||||||
rotateCW: () => scene.playfield.piece.rotate(ROTATION.CW),
|
rotateCW: () => scene.playfield.piece.rotate(ROTATION.CW)? scene.rotateSound.stop() && scene.rotateSound.play() : scene.hitSound.stop() && scene.hitSound.play(),
|
||||||
|
|
||||||
rotateCCW: () => scene.playfield.piece.rotate(ROTATION.CCW),
|
rotateCCW: () => scene.playfield.piece.rotate(ROTATION.CCW)? scene.rotateSound.stop() && scene.rotateSound.play() : scene.hitSound.stop() && scene.hitSound.play(),
|
||||||
|
|
||||||
softDrop: function () {
|
softDrop: function () {
|
||||||
if (scene.playfield.piece.move(TRANSLATION.DOWN)) stats.score++
|
if (scene.playfield.piece.move(TRANSLATION.DOWN)) {
|
||||||
|
stats.score++
|
||||||
|
scene.moveSound.stop()
|
||||||
|
scene.moveSound.play()
|
||||||
|
} else {
|
||||||
|
scene.floorSound.stop()
|
||||||
|
scene.floorSound.play()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
hardDrop: function () {
|
hardDrop: function () {
|
||||||
|
|||||||
BIN
audio/floor.ogg
Normal file
BIN
audio/floor.ogg
Normal file
Binary file not shown.
BIN
audio/hit.mp3
Normal file
BIN
audio/hit.mp3
Normal file
Binary file not shown.
BIN
audio/move.ogg
Normal file
BIN
audio/move.ogg
Normal file
Binary file not shown.
BIN
audio/rotate.ogg
Normal file
BIN
audio/rotate.ogg
Normal file
Binary file not shown.
@@ -47,17 +47,37 @@ export class TetraScene extends THREE.Scene {
|
|||||||
this.lineClearSound = new THREE.Audio(listener)
|
this.lineClearSound = new THREE.Audio(listener)
|
||||||
audioLoader.load('audio/line-clear.ogg', function( buffer ) {
|
audioLoader.load('audio/line-clear.ogg', function( buffer ) {
|
||||||
this.lineClearSound.setBuffer(buffer)
|
this.lineClearSound.setBuffer(buffer)
|
||||||
|
this.lineClearSound.setVolume(settings.sfxVolume/100)
|
||||||
}.bind(this))
|
}.bind(this))
|
||||||
this.tetrisSound = new THREE.Audio(listener)
|
this.tetrisSound = new THREE.Audio(listener)
|
||||||
audioLoader.load('audio/tetris.ogg', function( buffer ) {
|
audioLoader.load('audio/tetris.ogg', function( buffer ) {
|
||||||
this.tetrisSound.setBuffer(buffer)
|
this.tetrisSound.setBuffer(buffer)
|
||||||
this.lineClearSound.setVolume(settings.sfxVolume/100)
|
|
||||||
this.tetrisSound.setVolume(settings.sfxVolume/100)
|
this.tetrisSound.setVolume(settings.sfxVolume/100)
|
||||||
this.hardDropSound.setVolume(settings.sfxVolume/100)
|
|
||||||
}.bind(this))
|
}.bind(this))
|
||||||
this.hardDropSound = new THREE.Audio(listener)
|
this.hardDropSound = new THREE.Audio(listener)
|
||||||
audioLoader.load('audio/hard-drop.wav', function( buffer ) {
|
audioLoader.load('audio/hard-drop.wav', function( buffer ) {
|
||||||
this.hardDropSound.setBuffer(buffer)
|
this.hardDropSound.setBuffer(buffer)
|
||||||
|
this.hardDropSound.setVolume(settings.sfxVolume/100)
|
||||||
|
}.bind(this))
|
||||||
|
this.hitSound = new THREE.Audio(listener)
|
||||||
|
audioLoader.load('audio/hit.mp3', function( buffer ) {
|
||||||
|
this.hitSound.setBuffer(buffer)
|
||||||
|
this.hitSound.setVolume(settings.sfxVolume/100)
|
||||||
|
}.bind(this))
|
||||||
|
this.floorSound = new THREE.Audio(listener)
|
||||||
|
audioLoader.load('audio/floor.ogg', function( buffer ) {
|
||||||
|
this.floorSoung.setBuffer(buffer)
|
||||||
|
this.floorSoung.setVolume(settings.sfxVolume/100)
|
||||||
|
}.bind(this))
|
||||||
|
this.moveSound = new THREE.Audio(listener)
|
||||||
|
audioLoader.load('audio/move.ogg', function( buffer ) {
|
||||||
|
this.moveSound.setBuffer(buffer)
|
||||||
|
this.moveSound.setVolume(settings.sfxVolume/100)
|
||||||
|
}.bind(this))
|
||||||
|
this.rotateSound = new THREE.Audio(listener)
|
||||||
|
audioLoader.load('audio/rotate.ogg', function( buffer ) {
|
||||||
|
this.rotateSound.setBuffer(buffer)
|
||||||
|
this.rotateSound.setVolume(settings.sfxVolume/100)
|
||||||
}.bind(this))
|
}.bind(this))
|
||||||
|
|
||||||
this.playfield = new Playfield(loadingManager)
|
this.playfield = new Playfield(loadingManager)
|
||||||
@@ -72,8 +92,8 @@ export class TetraScene extends THREE.Scene {
|
|||||||
switch (theme) {
|
switch (theme) {
|
||||||
case "Plasma":
|
case "Plasma":
|
||||||
this.ambientLight.intensity = 1
|
this.ambientLight.intensity = 1
|
||||||
this.directionalLight.intensity = 1
|
this.directionalLight.intensity = 3
|
||||||
this.directionalLight.position.set(5, -20, 20)
|
this.directionalLight.position.set(5, -20, -10)
|
||||||
this.music.src = "audio/Moon-Over-Moscow-DJ-ResiDance-Mix-2022.mp3"
|
this.music.src = "audio/Moon-Over-Moscow-DJ-ResiDance-Mix-2022.mp3"
|
||||||
this.background = new THREE.Color(0xffffff)
|
this.background = new THREE.Color(0xffffff)
|
||||||
this.fog.color.set(0xffffff)
|
this.fog.color.set(0xffffff)
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ export class InstancedMino extends THREE.InstancedMesh {
|
|||||||
bumpScale: 1.5,
|
bumpScale: 1.5,
|
||||||
envMap: environment,
|
envMap: environment,
|
||||||
envMapIntensity: 5,
|
envMapIntensity: 5,
|
||||||
roughness: 0.07,
|
roughness: 0.03,
|
||||||
metalness: 1,
|
metalness: 1,
|
||||||
transparent: true,
|
transparent: true,
|
||||||
}, 8, 8)
|
}, 8, 8)
|
||||||
@@ -112,7 +112,7 @@ export class InstancedMino extends THREE.InstancedMesh {
|
|||||||
bumpScale: 1.5,
|
bumpScale: 1.5,
|
||||||
envMap: environment,
|
envMap: environment,
|
||||||
envMapIntensity: 5,
|
envMapIntensity: 5,
|
||||||
roughness: 0.07,
|
roughness: 0.03,
|
||||||
metalness: 1,
|
metalness: 1,
|
||||||
transparent: true,
|
transparent: true,
|
||||||
}, 1, 1)
|
}, 1, 1)
|
||||||
@@ -168,20 +168,10 @@ InstancedMino.prototype.materials = {
|
|||||||
envMap: environment,
|
envMap: environment,
|
||||||
side: THREE.DoubleSide,
|
side: THREE.DoubleSide,
|
||||||
transparent: true,
|
transparent: true,
|
||||||
opacity: 0.55,
|
opacity: 0.66,
|
||||||
roughness: 0.1,
|
roughness: 0.1,
|
||||||
metalness: 0.95,
|
metalness: 0.95,
|
||||||
}),
|
onBeforeCompile: shader => {
|
||||||
Space: new THREE.MeshStandardMaterial({
|
|
||||||
envMap: environment,
|
|
||||||
side: THREE.DoubleSide,
|
|
||||||
transparent: true,
|
|
||||||
opacity: 0.66,
|
|
||||||
roughness: 0.01,
|
|
||||||
metalness: 0.99,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
InstancedMino.prototype.materials['Plasma'].onBeforeCompile = shader => {
|
|
||||||
shader.vertexShader = `
|
shader.vertexShader = `
|
||||||
varying vec3 vPos;
|
varying vec3 vPos;
|
||||||
${shader.vertexShader}
|
${shader.vertexShader}
|
||||||
@@ -196,7 +186,9 @@ InstancedMino.prototype.materials['Plasma'].onBeforeCompile = shader => {
|
|||||||
transformed += normal * n;
|
transformed += normal * n;
|
||||||
`
|
`
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class Mino extends THREE.Object3D {
|
class Mino extends THREE.Object3D {
|
||||||
@@ -498,10 +490,10 @@ class Playfield extends THREE.Group {
|
|||||||
color: COLORS.RETRO,
|
color: COLORS.RETRO,
|
||||||
map: retroEdgeTexture,
|
map: retroEdgeTexture,
|
||||||
bumpMap: retroEdgeTexture,
|
bumpMap: retroEdgeTexture,
|
||||||
|
bumpScale: 1.5,
|
||||||
envMap: environment,
|
envMap: environment,
|
||||||
envMapIntensity: 5,
|
envMapIntensity: 5,
|
||||||
bumpScale: 1.5,
|
roughness: 0.03,
|
||||||
roughness: 0.07,
|
|
||||||
metalness: 1
|
metalness: 1
|
||||||
})
|
})
|
||||||
this.retroEdge = new THREE.Mesh(
|
this.retroEdge = new THREE.Mesh(
|
||||||
|
|||||||
Reference in New Issue
Block a user