Missile Command - Adding Sound

Having played my version without sound and now the latest one, it is easy to conclude that sound maketh-the-game! It was almost as if my previous version had taken a vow of silence for 10 years and was then allowed to sing to the heavens. Anyway, enough about that. It’s time to add noises to the game in part 6 of my series on creating a Missile Command clone in Scratch. There are three places that I would most like to add audio to:

  1. When I fire a defensive missile
  2. When an alien missile comes hurtling down towards me and,
  3. When I miss the alien missile and it hits my base (the bottom of the screen).

A really good source of free to use sounds that I have found is FreeSound (http://www.freesound.org). It is free to sign up and ticks all those boxes about respecting copyright that we are all teaching the children (right?!). I would urge some caution however because the there are items that can appear (depending on what you search for), that are very much inappropriate. My advice would be to use the site to download files you think are suitable, and let the children choose from those on your network drive.

After I had a good look around, I came up with three that I particularly liked. My missile firing will be a kind of explosion, the alien missiles returning will be a missile launching sound and when I die, I decided to use a voice screaming (A bit dramatic, but I wasn’t keen on another explosion). Thanks go to Gheorghelaza, Nbs Dark and smcameron for each of these sounds!

Adding in the effects is really straight forward but it is worth mentioning that there doesn’t appear to be a way to import sounds that all the sprites can use, so be careful when you add them in to make sure you are currently on the correct sprite. Either use my sounds (in the zip file at the bottom) or choose your own but for each, these are the steps required.

Cross Hairs

Click on this sprite, select the sound tab and then click on the import button. The file I used was 94185__nbs-dark_explosion.wav. Then, in the script, simply use the play sound command to add it into the appropriate place.

Enemy-1 (When they begin)

Here is where we begin to see alien missiles come down, so right at the top is where we need to add the sound effect for those. Importing the sounds is as above (I used 51468_smcameron_missile-launch-2). Just place the play command here:

Enemy-1 (When we miss)

Import our sound for when a missile is missed (it hits us) and then add another play command at the bottom. Mine is using 149825_gheorghelaza_desperate-shout -- what else?!) You can also guess where it will go, right? Look for the bit where we take away a player life.

Testing

Testing is a really important part of writing software and I hope that you have been doing it as you go along. Write a little, test it. Write some more, test it, and so on. That’s a good philosophy. After adding each of the sounds, make sure you check to see it is all working as you would expect. Here’s my game (minus the soft tones of my voice) and the complete script (with the sound files). Note, I have removed the extra scripts that aren’t being used, to clean things up a little.

Next time, we will add an opening screen to the game to make it look a little more polished.


Hi! Did you find this useful or interesting? I have an email list coming soon, but in the meantime, if you ready anything you fancy chatting about, I would love to hear from you. You can contact me here or at stephen ‘at’ logicalmoon.com