improve step sound
This commit is contained in:
@@ -211,7 +211,14 @@ window.Minecraft = class {
|
|||||||
let soundName = block.getSound().getBreakSound();
|
let soundName = block.getSound().getBreakSound();
|
||||||
|
|
||||||
// Play sound
|
// Play sound
|
||||||
this.soundManager.playSound(soundName, hitResult.x + 0.5, hitResult.y + 0.5, hitResult.z + 0.5, 1.0);
|
this.soundManager.playSound(
|
||||||
|
soundName,
|
||||||
|
hitResult.x + 0.5,
|
||||||
|
hitResult.y + 0.5,
|
||||||
|
hitResult.z + 0.5,
|
||||||
|
1.0,
|
||||||
|
1.0
|
||||||
|
);
|
||||||
|
|
||||||
// Destroy block
|
// Destroy block
|
||||||
this.world.setBlockAt(hitResult.x, hitResult.y, hitResult.z, 0);
|
this.world.setBlockAt(hitResult.x, hitResult.y, hitResult.z, 0);
|
||||||
@@ -241,7 +248,11 @@ window.Minecraft = class {
|
|||||||
// Don't place blocks if the player is standing there
|
// Don't place blocks if the player is standing there
|
||||||
if (!placedBoundingBox.intersects(this.player.boundingBox)) {
|
if (!placedBoundingBox.intersects(this.player.boundingBox)) {
|
||||||
let typeId = this.inventory.getItemInSelectedSlot();
|
let typeId = this.inventory.getItemInSelectedSlot();
|
||||||
if (typeId !== 0) {
|
|
||||||
|
// Get previous block
|
||||||
|
let prevTypeId = this.world.getBlockAt(x, y, z);
|
||||||
|
|
||||||
|
if (typeId !== 0 && prevTypeId !== typeId) {
|
||||||
// Place block
|
// Place block
|
||||||
this.world.setBlockAt(x, y, z, typeId);
|
this.world.setBlockAt(x, y, z, typeId);
|
||||||
|
|
||||||
@@ -252,7 +263,14 @@ window.Minecraft = class {
|
|||||||
// Play sound
|
// Play sound
|
||||||
let sound = block.getSound();
|
let sound = block.getSound();
|
||||||
let soundName = sound.getStepSound();
|
let soundName = sound.getStepSound();
|
||||||
this.soundManager.playSound(soundName, hitResult.x + 0.5, hitResult.y + 0.5, hitResult.z + 0.5, sound.getPitch() * 0.8);
|
this.soundManager.playSound(
|
||||||
|
soundName,
|
||||||
|
hitResult.x + 0.5,
|
||||||
|
hitResult.y + 0.5,
|
||||||
|
hitResult.z + 0.5,
|
||||||
|
1.0,
|
||||||
|
sound.getPitch() * 0.8
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ window.Player = class {
|
|||||||
|
|
||||||
// Play sound
|
// Play sound
|
||||||
if (!block.isLiquid()) {
|
if (!block.isLiquid()) {
|
||||||
this.minecraft.soundManager.playSound(sound.getStepSound(), this.x, this.y, this.z, sound.getPitch());
|
this.minecraft.soundManager.playSound(sound.getStepSound(), this.x, this.y, this.z, 0.15, sound.getPitch());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ window.SoundManager = class {
|
|||||||
return sound;
|
return sound;
|
||||||
}
|
}
|
||||||
|
|
||||||
playSound(name, x, y, z, pitch) {
|
playSound(name, x, y, z, volume, pitch) {
|
||||||
let pool = this.soundPool[name];
|
let pool = this.soundPool[name];
|
||||||
|
|
||||||
if (typeof pool === "undefined") {
|
if (typeof pool === "undefined") {
|
||||||
@@ -76,7 +76,8 @@ window.SoundManager = class {
|
|||||||
// Update position
|
// Update position
|
||||||
sound.position.set(x, y, z);
|
sound.position.set(x, y, z);
|
||||||
|
|
||||||
// Update pitch
|
// Update volume and pitch
|
||||||
|
sound.setVolume(volume);
|
||||||
sound.filters[0].frequency.setValueAtTime(12000 * pitch, sound.context.currentTime);
|
sound.filters[0].frequency.setValueAtTime(12000 * pitch, sound.context.currentTime);
|
||||||
|
|
||||||
// Play sound
|
// Play sound
|
||||||
|
|||||||
Reference in New Issue
Block a user