not bad
This commit is contained in:
parent
2741b93dea
commit
434f07cc4e
103 changed files with 8387 additions and 8152 deletions
22
js/audio.js
22
js/audio.js
|
|
@ -107,27 +107,11 @@ const audio = {
|
|||
categoryOn(category = "ops") {
|
||||
return Boolean(this.categoryEnabled[category] ?? true);
|
||||
},
|
||||
gainFor(category = "ops", base = 1) {
|
||||
return Math.max(0.1, Number(base) || 1) * (this.categoryGain?.[category] ?? 1);
|
||||
},
|
||||
sampleVolumeFor(key = "") {
|
||||
const category = this.categoryFor(key, key.startsWith("voice") ? "voice" : "ops");
|
||||
const base = category === "voice" ? 0.95 : 1.0;
|
||||
return Math.min(1, base * Math.max(1, (this.categoryGain?.[category] ?? 1) * 0.35) * (this.idGain?.[key] ?? 1));
|
||||
},
|
||||
distanceGain(opts = {}) {
|
||||
if (!opts || opts.category === "notify" || !Number.isFinite(opts.x) || !Number.isFinite(opts.y)) return 1;
|
||||
const w = window.world;
|
||||
if (!w || !w.worldToScreen) return 1;
|
||||
const p = w.worldToScreen(opts.x, opts.y);
|
||||
const margin = 140;
|
||||
const vw = w.viewportW || w.w || 1000;
|
||||
const vh = w.viewportH || w.h || 720;
|
||||
if (p.x < -margin || p.y < -margin || p.x > vw + margin || p.y > vh + margin) return 0;
|
||||
const cx = vw / 2, cy = vh / 2;
|
||||
const d = Math.hypot(p.x - cx, p.y - cy);
|
||||
return clamp(1 - d / Math.max(vw, vh) * 0.65, 0.35, 1);
|
||||
},
|
||||
beginVoice(dur = 0.1) {
|
||||
this.activeVoices = (this.activeVoices || 0) + 1;
|
||||
setTimeout(() => { this.activeVoices = Math.max(0, (this.activeVoices || 0) - 1); }, Math.max(60, dur * 1000 + 80));
|
||||
|
|
@ -137,11 +121,6 @@ const audio = {
|
|||
this.categoryEnabled[category] = Boolean(on);
|
||||
this.saveSettings();
|
||||
},
|
||||
toggleCategory(category) {
|
||||
if (!(category in this.categoryEnabled)) return false;
|
||||
this.setCategory(category, !this.categoryEnabled[category]);
|
||||
return this.categoryEnabled[category];
|
||||
},
|
||||
setEnabled(on) {
|
||||
this.enabled = Boolean(on);
|
||||
if (this.enabled) this.ensure();
|
||||
|
|
@ -324,7 +303,6 @@ const audio = {
|
|||
grab() { this.play("sfx_grab", { category: "ops", minGap: 0.08 }); },
|
||||
drop() { this.play("sfx_drop", { category: "ops", minGap: 0.08 }); },
|
||||
waterHose() { this.play("sfx_water_hose", { category: "ops", minGap: 0.20 }); },
|
||||
waterClean() { this.play("sfx_water_clean", { category: "ops", minGap: 0.22 }); },
|
||||
ballHit() { this.play("sfx_ball_hit", { category: "ops", minGap: 0.08 }); },
|
||||
stoneImpact() { this.play("sfx_stone_impact", { category: "ops", minGap: 0.18 }); },
|
||||
genkotsuImpact() { this.play("sfx_genkotsu_impact", { category: "ops", minGap: 0.20 }); setTimeout(() => this.play("sfx_ground_rumble", { category: "ops", minGap: 0.20 }), 80); },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue