Page 12 of 15 Adding Bombs Although the game can already be fun to play, there is something missing. You cannot lose! You can just keep clicking randomly, which is not really much fun. Hence, we are going to add bombs to the game. If you click on a bomb you will lose and the game will end. Bombs will be static. They won't move, but their number keeps increasing to make the game more and more difficult over time.
The bomb sprite is already present but we atill need a sound effect for it. Press the button with the speaker to add a sound. Give is an appropriate name, press the Load Sound button and select `explosion.wav`. Press OK to close the sound form.
Now create the bomb object by clicking on the blue ball button. Give the object an appropriate name and the bomb sprite. We want the bomb to appear in a random place. To this end, add the Create event. In it place the action to jump to a random location.
When the use clicks on it we want the game to end. So add the Mouse event Left pressed. As a first action we want to play the explode sound so add the play sound action (from the main1 tab) and select the explode sound. Next we want to wait a little while to let the player realize he lost. From the main2 tab, drag the sleep action (with the zzz on it) and place it below the play sound action. The default values are fine, so press OK.
As a next step we want to show a highscore list. This is very easy in Game Maker. From the score tab, drag the show highscore action (with the 1,2,3 in it). In the form you can set quite some values. As a background you can choose the wood background. You also can change the colors and the font if you like, for example as follows:
As a final step we need the action to restart the game, which can be found in the main2 tab. The action list should now look as follows:
Make sure the order of the actions is correct. (If not, drag them to the correct location.) That finishes the bomb object so better press the OK button to close the form. To test the game, place one or two bomb objects in the room. Save the game, run it, catch some fruit and then click on a bomb. An explosion sound should be heard and the highscore list should show. Note that in this list you can add your name if you get a new high score.