Increase hearing radius to 20 and suppress repeated wall-hit sound

This commit is contained in:
Jage9
2026-02-22 03:30:26 -05:00
parent 43e0709566
commit 5e83066119
3 changed files with 13 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
// Maintainer-controlled web client version.
// Format: YYYY.MM.DD Rn (example: 2026.02.20 R2)
window.CHGRID_WEB_VERSION = "2026.02.22 R143";
window.CHGRID_WEB_VERSION = "2026.02.22 R144";
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
window.CHGRID_TIME_ZONE = "America/Detroit";

View File

@@ -172,6 +172,7 @@ const state = createInitialState();
const renderer = new CanvasRenderer(dom.canvas);
const audio = new AudioEngine();
let worldGridSize = GRID_SIZE;
let lastWallCollisionDirection: string | null = null;
let localStream: MediaStream | null = null;
let outboundStream: MediaStream | null = null;
let statusTimeout: number | null = null;
@@ -900,18 +901,26 @@ function handleMovement(): void {
if (state.keysPressed.ArrowLeft) dx = -1;
if (state.keysPressed.ArrowRight) dx = 1;
if (dx === 0 && dy === 0) return;
if (dx === 0 && dy === 0) {
lastWallCollisionDirection = null;
return;
}
const nextX = state.player.x + dx;
const nextY = state.player.y + dy;
const attemptedDirection = `${dx},${dy}`;
if (nextX < 0 || nextY < 0 || nextX >= worldGridSize || nextY >= worldGridSize) {
state.player.lastMoveTime = now;
if (lastWallCollisionDirection !== attemptedDirection) {
void audio.playSample(WALL_SOUND_URL, 1);
lastWallCollisionDirection = attemptedDirection;
}
return;
}
state.player.x = nextX;
state.player.y = nextY;
lastWallCollisionDirection = null;
persistPlayerPosition();
state.player.lastMoveTime = now;
void audio.playSample(randomFootstepUrl(), FOOTSTEP_GAIN);

View File

@@ -1,5 +1,5 @@
export const GRID_SIZE = 41;
export const HEARING_RADIUS = 15;
export const HEARING_RADIUS = 20;
export const MOVE_COOLDOWN_MS = 200;
export type ItemType = 'radio_station' | 'dice' | 'wheel' | 'clock' | 'widget';