Audio Engineering
Audio System Implementation
Sound is crucial for feedback and immersion. We utilize the Web Audio API or a lightweight library like Howler.js to manage sound assets.
Sound Categories
Global Ambience (BGM):
Looped tracks (Synthwave/Ambient) that play in the background.
Dynamic Layering: The music intensity can shift based on the city's state. If the city is in debt or has high crime, the music shifts to a darker, more minor-key track.
Spatial Sound Effects (SFX):
Sounds are triggered based on the camera position.
When the user zooms into an Industrial Zone, the volume of "Factory Machinery" loops increases.
When the user zooms into a Residential Zone, "Birds" or "Traffic" sounds become dominant.
UI Feedback:
Short, crisp sounds (clicks, hover effects) provide tactile feedback for user interactions within the menus.
Optimization
To prevent memory leaks, audio sprites are used (combining multiple short sounds into one file). Sounds are lazily loaded, meaning the "Power Plant" sound is only loaded into memory when the player actually builds a Power Plant.
Last updated
