Ghost Invaders
5 Ghosts Fight Back

Section Menu

Ghost Invaders Home | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

To make the game more interesting, we need to give the ghosts some way to fight back. The ghosts are going to drop bombs. If a bomb hits the ship, the player will lose a life.

Start by creating a new sprite called spr_bomb and load the bomb graphic.

Game Maker Screenshot

Create an object using this sprite. Call the object obj_bomb.

Game Maker Screenshot

We want the ghosts to drop bombs at random intervals. We also want to make it so that as we shoot more of the ghosts, the ones that are left drop more bombs.

Add a Step event to the Ghost object window. Then drag in the Test Chance icon (looks like a dice). Fill in the pop-up as shown.

Game Maker Screenshot

Increase or decrease the number 20 to vary how often the bombs appear.

Add a Start Block (up arrow) and then a Create Instance icon. Fill in the pop-up as shown in the screenshot.

Game Maker Screenshot

Drag in an End Block (down arrow). Your window should look like the screenshot.

Game Maker Screenshot

Now we need to make sure that the bombs fall down the screen. The actions for this are just like the ones we used to make the bullets fly up the screen except that we move the bombs downwards.

Open up the Bomb object window. Add a Create Event. Drag in a Move Fixed icon and fill in the pop-up as shown.

Game Maker Screenshot

That gives you this,

Game Maker Screenshot

We want to destroy the bombs when they reach the bottom of the screen. To do this add a Intersect Boundary Event (other). Drag in a Destroy Instance icon so that you have the following,

Game Maker Screenshot

Create a new sound called snd_dead and load one of the sounds that you haven't used.

Go back to the bomb object window and add a Collision Event for when the bomb hits the ship. We need to do the following things,

  • Destroy the bomb
  • Reduce the number of lives by 1
  • Play the dead sound

Use the Destroy Instance icon to remove the bomb from the screen.
Use the Set Lives icon to set the number of lives to relative -1.
Use the Play Sound icon to play the dead sound.
You should end up with the following.

Game Maker Screenshot

Save and test the game so far. Make sure that the bombs fall correctly and that they come more often when you shoot some of the ghosts.

⇐ Previous | Next ⇒