3 Creating The Asteroids

Section Menu

Asteroids Home | 1 | 2 | 3 | 4 | 5

We will need 3 types of asteroid. Large asteroids split into 3 medium asteroids when hit with a bullet. Medium asteroids split into 3 smaller asteroids when hit.

Create 3 new sprites called spr_roid_big, spr_roid_medium, spr_roid_small. Associate the 3 asteroid graphics with the sprites. Create 3 objects called obj_roid_big, obj_roid_medium, obj_roid_small.

Open up the window for the big asteroid and add a Create event. Drag in the Move Free icon and fill in the pop-up as below,

Game Maker Screenshot

Add an Outside Room event and drag in a Wrap Screen icon so that the asteroid will return to the opposite end of the screen when it reaches the edge.

Game Maker Screenshot

The other 2 asteroids will need the same 2 events with the same actions. The only difference will be in the Move Free settings. As the asteroids get smaller, they move more quickly. So the Move Free windows should be filled in as follows,

Game Maker ScreenshotGame Maker Screenshot

Add 2 large asteroids to the edge of the room and run the game to check the movement. Adjust the speed settings if you think it's needed.

Load one of the sounds for you to play when an asteroid is hit by a bullet call it snd_boom.

Go to the large asteroid object window and add a Collision event with obj_bullet. Drag in a Play Sound icon and play the sound that you created.

Now drag in a Create Instance icon and fill in the window as shown,

Game Maker Screenshot

Add another one of these and fill them in the same way.

Finally drag in a Destroy Instance icon so that you have the following,

Game Maker Screenshot

Save and test what happens when you hit the asteroid. You will need to do the same for the medium sized asteroid except that you will create 3 small asteroids.

In the small asteroid object window, the collision event just needs to play the sound and destroy the asteroid.

Test that all of the asteroids destroy as they should.

Now open up the bullet object window. When the bullet hits an asteroid, we need to destroy the bullet and increase the score. I am going to increase the score by 10 for a large asteroid, 20 for a medium asteroid and 30 for a small one. Add a collision event to the bullet object window. The collision should be with the obj_roid_big. Drag in a Set Score icon and fill it in as shown.

Game Maker Screenshot

Follow that with a Destroy Instance icon.

Do the same for the other 2 asteroids with settings for the score that suit your mood.

Save and test the game so far.

⇐ Previous | Next ⇒