Session 4: Sound effects system with Web Audio API
This commit is contained in:
+9
-2
@@ -32,6 +32,7 @@ const Game = {
|
||||
this.setupEventListeners();
|
||||
this.startGameLoop();
|
||||
this.startAutoSave();
|
||||
Audio.init();
|
||||
UI.init();
|
||||
Stats.init();
|
||||
console.log('🌌 Cosmic Garden initialized!');
|
||||
@@ -98,7 +99,10 @@ const Game = {
|
||||
const amount = this.getClickPower();
|
||||
this.addStardust(amount);
|
||||
this.state.totalClicks++;
|
||||
|
||||
|
||||
// Audio feedback
|
||||
Audio.playClick();
|
||||
|
||||
// Visual feedback
|
||||
UI.showFloatingText(event.clientX, event.clientY, `+${this.formatNumber(amount)}`);
|
||||
Particles.createClickParticles(event.clientX, event.clientY, 8);
|
||||
@@ -181,7 +185,10 @@ const Game = {
|
||||
this.state.buildings[buildingId] = (this.state.buildings[buildingId] || 0) + 1;
|
||||
|
||||
UI.showNotification(`Bought ${BUILDINGS[buildingId].name}!`, 'success');
|
||||
|
||||
|
||||
// Audio feedback
|
||||
Audio.playPurchase();
|
||||
|
||||
// Particle effect on building purchase
|
||||
const card = document.getElementById(`building-${buildingId}`);
|
||||
if (card) {
|
||||
|
||||
Reference in New Issue
Block a user