@@ -73,22 +73,28 @@ pub fn update_loot(game: &mut Game, dt: f32) {
7373 LootType :: Scrap ( amount) => {
7474 game. ship . scrap += amount;
7575 game. mission_scrap_collected += amount;
76+ game. audio_cues . push ( crate :: audio:: AudioCue :: PickupScrap ) ;
7677 }
7778 LootType :: RareMetal ( amount) => {
7879 game. ship . rare_metal += amount;
7980 game. mission_rare_metal_collected += amount;
81+ game. audio_cues . push ( crate :: audio:: AudioCue :: PickupScrap ) ;
8082 }
8183 LootType :: HealthPack ( hp) => {
8284 game. ship . heal ( hp as f32 ) ;
85+ game. audio_cues . push ( crate :: audio:: AudioCue :: PickupHealth ) ;
8386 }
8487 LootType :: RapidFireBoost => {
8588 game. ship . rapid_fire_timer = RAPID_FIRE_DURATION ;
89+ game. audio_cues . push ( crate :: audio:: AudioCue :: PickupScrap ) ;
8690 }
8791 LootType :: BigBulletBoost => {
8892 game. ship . big_bullet_timer = BIG_BULLET_DURATION ;
93+ game. audio_cues . push ( crate :: audio:: AudioCue :: PickupScrap ) ;
8994 }
9095 LootType :: Shield ( hp) => {
9196 game. ship . activate_shield ( hp as f32 , SHIELD_DURATION ) ;
97+ game. audio_cues . push ( crate :: audio:: AudioCue :: ShieldOn ) ;
9298 }
9399 }
94100 items_to_remove. push ( i) ;
@@ -130,6 +136,7 @@ fn handle_bullet_bullet_collisions(game: &mut Game) {
130136 if ( b1. pos - b2. pos ) . length ( ) < b1. radius + b2. radius {
131137 let collision_pos = ( b1. pos + b2. pos ) * 0.5 ;
132138 game. explosions . push ( Explosion :: new ( collision_pos, 0.5 ) ) ;
139+ game. audio_cues . push ( crate :: audio:: AudioCue :: ExplosionSmall ) ;
133140 bullets_to_remove. insert ( i) ;
134141 bullets_to_remove. insert ( j) ;
135142 break ;
@@ -161,6 +168,7 @@ fn handle_player_bullet_collisions(game: &mut Game) {
161168 if ( b. pos - game. asteroids [ i] . pos ) . length ( ) < game. asteroids [ i] . radius + b. radius {
162169 game. score += 100 ;
163170 let asteroid = game. asteroids . remove ( i) ;
171+ game. audio_cues . push ( crate :: audio:: AudioCue :: ExplosionSmall ) ;
164172
165173 let source = if asteroid. is_rare {
166174 LootSource :: RareAsteroid
@@ -194,6 +202,7 @@ fn handle_player_bullet_collisions(game: &mut Game) {
194202 }
195203 game. mission_kills += 1 ;
196204 game. explosions . push ( Explosion :: new ( e. pos , 0.4 ) ) ;
205+ game. audio_cues . push ( crate :: audio:: AudioCue :: ExplosionBig ) ;
197206 false
198207 } else {
199208 true
@@ -225,6 +234,7 @@ fn handle_player_bullet_collisions(game: &mut Game) {
225234 game. boss = None ;
226235 game. score += ( max_health as u32 ) * SCORE_PER_ENEMY_HP ;
227236 game. explosions . push ( Explosion :: new ( pos, 0.8 ) ) ;
237+ game. audio_cues . push ( crate :: audio:: AudioCue :: ExplosionBig ) ;
228238 if let Some ( loot) = generate_loot ( pos, LootSource :: EnemyBoss , game. difficulty ) {
229239 game. loot_items . push ( loot) ;
230240 }
@@ -239,6 +249,11 @@ fn handle_enemy_bullet_collisions(game: &mut Game) -> bool {
239249 && ( b. pos - game. ship . pos ) . length ( ) < SHIP_RADIUS + b. radius
240250 {
241251 game. explosions . push ( Explosion :: new ( game. ship . pos , 0.5 ) ) ;
252+ if game. ship . has_shield ( ) {
253+ game. audio_cues . push ( crate :: audio:: AudioCue :: ShieldHit ) ;
254+ } else {
255+ game. audio_cues . push ( crate :: audio:: AudioCue :: ShipHit ) ;
256+ }
242257 let damage = b. damage * game. difficulty . damage_mult ( ) ;
243258 if game. ship . take_damage ( damage, game. score ) {
244259 game_over = true ;
@@ -266,6 +281,11 @@ fn handle_ship_entity_collisions(game: &mut Game) -> bool {
266281 game. ship . pos ,
267282 ( asteroid_radius / LARGE_ASTEROID_RADIUS ) . clamp ( 0.3 , 0.8 ) ,
268283 ) ) ;
284+ if game. ship . has_shield ( ) {
285+ game. audio_cues . push ( crate :: audio:: AudioCue :: ShieldHit ) ;
286+ } else {
287+ game. audio_cues . push ( crate :: audio:: AudioCue :: ShipHit ) ;
288+ }
269289 if game. ship . take_damage ( asteroid_damage, game. score ) {
270290 game_over = true ;
271291 }
@@ -279,6 +299,11 @@ fn handle_ship_entity_collisions(game: &mut Game) -> bool {
279299 {
280300 let damage = BASE_KAMIKAZE_DAMAGE * game. difficulty . damage_mult ( ) ;
281301 game. explosions . push ( Explosion :: new ( e. pos , 0.6 ) ) ;
302+ if game. ship . has_shield ( ) {
303+ game. audio_cues . push ( crate :: audio:: AudioCue :: ShieldHit ) ;
304+ } else {
305+ game. audio_cues . push ( crate :: audio:: AudioCue :: ShipHit ) ;
306+ }
282307 if game. ship . take_damage ( damage, game. score ) {
283308 game_over = true ;
284309 }
0 commit comments