Before we’re ready to sit down and play our game for hours, let’s add just a few sound effects. In particular, we’ll create sounds when a bullet is fired and when a gallery target is hit. If you remember Chapter 12, “Sounds,” you’ll know that we need to start by loading our sounds, which we’ll do right after the Welcome function at the beginning of the game:
Return EndIf Wend End Function ; Loading the sounds phaser=LoadSound("phaser.wav") explosion=LoadSound("explode.wav")
Next we need to associate the sound whenever a bullet is fired:
;Firing bullets If KeyHit (SPACE_BAR) And reload=0 PlaySound phaser PositionEntity bullet(t),EntityX(gun,1),EntityY(gun,1),EntityZ(gun,1)
We also need to add a sound whenever a gallery item is destroyed, ...