Skip to content

Audio music and sound#30

Open
clintjeff2 wants to merge 2 commits into
Bitcoindefi:mainfrom
clintjeff2:audio-music-and-sound
Open

Audio music and sound#30
clintjeff2 wants to merge 2 commits into
Bitcoindefi:mainfrom
clintjeff2:audio-music-and-sound

Conversation

@clintjeff2

Copy link
Copy Markdown

I have implemented a comprehensive audio system for the 'Human vs Bots' game demo.

Key features include:

  • Audio Manager: A new audio.js file houses the AudioManager class, which manages the Web Audio API lifecycle, separate gain nodes for a mixer effect (Master, Music, SFX), and asset loading.
  • Game Integration: I mapped sound effects to essential game actions including unit selection (click), movement, attacks, unit production, and turn transitions.
  • Music Management: The system automatically switches between menu music and battle music when a match starts or ends.
  • Audio Controls UI: A new 'Audio Settings' section was added to the menu drawer, featuring independent volume sliders for Master, Music, and SFX, along with a Mute toggle.
  • Persistence: User volume preferences are saved in localStorage and restored upon reloading the game.
  • Policy Compliance: The audio context initializes only after the first user interaction (e.g., opening the menu or clicking the arena) to follow modern browser autoplay policies.

I verified the implementation using a Playwright script that confirmed the triggering of music and SFX events and captured a screenshot of the new UI.


Closes #25

google-labs-jules Bot and others added 2 commits June 26, 2026 01:18
- Implement AudioManager using Web Audio API for low-latency playback.
- Add royalty-free music and SFX assets (via URL for demo purposes).
- Map SFX to game events: click, movement, attack, production, and end turn.
- Implement music switching between menu and gameplay.
- Add Audio Settings UI with volume sliders and mute toggle.
- Persist volume settings in localStorage.
- Comply with browser autoplay policies by initializing on user interaction.

Co-authored-by: clintjeff2 <119521983+clintjeff2@users.noreply.github.com>
…1149493533

Audio system: music and sound effects implementation
@clintjeff2

Copy link
Copy Markdown
Author

@leocagli , kindly review and merge.

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Audio: música y efectos de sonido

1 participant