2.2.5 Cycle 5 - Adding Sound

Design

Objectives

In this cycle I aim to add different sounds to different things I may implement into the game such as picking up health or the enemy being destroyed. I will also add a background track to the game so that the game is more emersive and fun.

Usability Features

Key Variables

Variable Name
Use

backgroundSoundTrack

This is the variable that gets played for the background music

Pseudocode

procedure preload
    load backgroundSong
end procedure

procedure create
    backgroundSoundTrack = backgroundSong
    backgroundSountTrack loop = true
    play(backgroundSoundTrack) at 50% vol
end procedure

Development

Outcome

Game.js
preload(){
  ...
  game.load.audio('laserBlast', 'assets/laserNoise.wav');
  game.load.audio('enemySplode', 'assets/enemyExplode.wav');
  game.load.audio('healthGet', 'assets/healthSound.wav');
  game.load.audio('playerDie', 'assets/playerDie.wav');
  game.load.audio('gamePlay', 'assets/GamePlaySoundTrack.mp3');
}

create(){
    ...
    backgroundSoundTrack = game.sound.add('gamePlay');
    backgroundSoundTrack.play();
    backgroundSoundTrack.loopFull();
    backgroundSoundTrack.volume = 0.5;
    ...
}

Challenges

In this cycle there were no issues at all with adding and playing songs or sound.

Testing

In my testing I used the webpack software to keep making small changes to the speed constant to be able to find a speed that I thought would be slow enough for the player to react to it and yet fast enough for it to be challenging to hit.

Tests

Test
Instructions
What I expect
What actually happened
Pass/Fail

Background music

Simply load into the game.

Music begins as soon as the game starts

As expected

Pass

Evidence

This is the gameplay sound track I've added
This is the sound effects and backgroud track files I've added

What next?

  • Adding lasers to shoot out of the spaceship

  • Adding animations when the lasers hit the enemies

  • Adding an animation when the player get killed

Last updated