Skip to content

Audio integration #9

@Otaiki1

Description

@Otaiki1

Overview

Add a full in-game audio layer — sound effects for all major game events, optional background music, and persistent volume settings.

Sound Effects

Event Sound Trigger
Piece selected Soft click (50ms) Tray hit in handleStart
Piece placed Thud/knock (120ms) Successful placePiece()
Line clear Swoosh + chime (350ms) Each row/col cleared
Multi-clear (2+ lines) Layered swoosh, brighter chime linesCleared >= 2 in one move
Combo trigger Bass hit + ring (400ms) newComboStreak > 0 with lines cleared
UNSTOPPABLE tier Power-up fanfare (600ms) Combo streak reaches 7
Game over Descending tone (500ms) isGameOver becomes true
Score submitted Success jingle (800ms) On-chain submission confirmed
Revival purchased Coin sound (300ms) Revive confirmed
Button tap Subtle UI click (30ms) All brutal-btn presses

Background Music

  • Off by default, toggled in Settings
  • Single ambient loop during gameplay
  • Pauses when pause menu is open
  • Recommended: "Sneaky Snitch" by Kevin MacLeod (CC BY 4.0) or equivalent 120–135 BPM loop

Volume Controls

Two sliders in Settings:

  • Sound Effects — persisted to localStorage key blokaz:sfx_volume
  • Music — persisted to localStorage key blokaz:music_volume

Implementation

  • src/audio/AudioManager.ts — singleton with play(event), setMusicVolume(v), setSfxVolume(v), pauseMusic(), resumeMusic()
  • Web Audio API directly (no library) for low-latency SFX
  • Lazy initialisation on first user gesture (browser autoplay policy)
  • Audio files in public/sounds/ as MP3, <50KB each
  • MiniPay: haptic navigator.vibrate() calls remain — audio is complementary

Files to Change

  • src/audio/AudioManager.ts — new singleton
  • src/components/GameScreen.tsx — call AudioManager.play(event) at each game event
  • src/components/LobbyScreen.tsx — button click audio
  • Settings screen — volume sliders
  • public/sounds/ — audio files

Contract change required: No

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions