Directions for Galactic Mail Game

Directions from the Game Maker’s Apprentice book by Jacob Habgood and Mark Overmars

Game Description

You play an intergalactic mail carrier who must deliver mail to a number of inhabited moons. He must safely steer a course from moon to moon while avoiding dangerous asteroids. The mail carrier is paid for each delivery he makes, but pay is deducted for time spent hanging around on moons. This adds pressure to the difficult task of orienting his rickety, old rocket, which he cannot steer very well in space.

When the rocket is on a moon, the arrow keys will rotate it to allow the launch direction to be set. The spacebar will launch the rocket, and the moon is removed from the screen to show that its mail has been delivered. In flight, the rocket will keep moving in the direction it is pointing in, with only a limited amount of control over its steering using the arrow keys. When things move outside the playing area, they will reappear on the other side to give the impression of a continuous world. The player will gain points for delivering mail, but points are deducted while waiting on a moon. This will encourage the player to move as quickly as possible from moon to moon. There will be different levels, with more asteroids to avoid. The game is over when the rocket is hit by an asteroid and a high-score table will be displayed.

Setting Game Maker into Advanced Mode:

Click the File menu and choose Advanced Mode. If there is a check mark, you are already in Advanced mode. If not, click on it to put one there.

Creating new sprite resources for the game:

  1. From Resources menu, choose Create Sprite.
  2. Click in the Name field and name it sprite_moon.
  3. Click Load Sprite choose Moon.png from Galactic Resources folder on network.
  4. Click Center button to move the origin of the sprite to its middle.
  5. Click OK to close form.
  6. Create sprites for the asteroid and explosion using Asteroid_strip180.png and Explosion_strip9.png. Make sure these get centered too.
  7. Create 2 rockets sprites: one for landing and one for flying. Create a sprite called sprite_landed using Landed_sprite72.png and another one called sprite_flying using Flying_strip72.png. Center these too.

FYI—these sprites have 72 different images that make up a complete 360 degree turning capability.

Creating new sound resources for the game:

1.  Select Create Sound from the Resources menu.

2.  Call the sound_explosion and click Load Sound. Choose Explosion.wav from the Resources folder.

3.  Close by clicking OK.

4.  Create sounds for bonus and music using the Bonus.wav and Music.mp3 files.

Creating the moon object:

1.  From the Resources menu, choose Create object.

2.  Name the object_moon and choose the moon sprite.

Adding a create event to the moon object:

1.  Click the Add Event button and choose Create.

2.  Include the Move Free action in the Actions list.

3.  Enter a Speed of 4 and type random(360) in the Direction property. This will make the moon move in random directions.

Now we will make the moon able to move off the edge of the room and appear on the other side.

Including a Wrap action for the moon object:

1.  Click the Add Event button, choose Other and select Outside Room from the pop up menu.

2.  Include the Wrap Screen action.

3.  Indicate that wrapping should occur in both directions.

4.  Click OK to close the Properties form.

Creating the Asteroid object:

1.  Create a new object called object_asteroid and assign using the asteroid sprite.

2.  On the left side, make the depth 10.

3.  Add the Create Event and include the Move Free action. Type random(360) in the Direction property and Speed of 4.

4.  Add the Other, Outside Room event and Wrap Screen action in both directions.

5.  Click OK to close the form.

Creating a room with moon and asteroid instances:

1.  Select Create Background from the Resources menu.

2.  Call the background_main, and click the Load Background choosing Background.png.

3.  Click OK to close the properties form.

4.  Select Create Room from the Resources menu.

5.  Select the settings tab and name the room_first. Provide the caption Galactic Mail.

6.  Select the backgrounds tab. Click the menu icon on the right where it says <no background> and select the background you created.

7.  Select the Objects tab and place some asteroids and moons in the room.

8.  Close the Room Properties form by clicking the green check mark.

Saving and running the game:

1.  Choose Save from the File menu. Save it to your U: drive.

2.  Select run normally from the Run menu.

Before moving on, check that the moons and asteroids are moving in random and different direction. Do they leave the room and appear on the other side of the screen? Do the asteroids pass behind the moons? If not, recheck the steps for making them move.

We need to create 2 moons--- one for landing and one to float through space. Making a separate object will allow us to single it out.

Creating the special moon object:

1.  Right click the moon object and select Duplicate. A copy of the moon will appear in the list.

2.  Change the name to object_specialmoon. USE THIS EXACT NAME so we can identify it later.

3.  Set the Depth to -5. This will make this moon in front of any others.

4.  Add an Other, Game Start event and include a Play Sound action (main 1 tab). Select the background music sound and set loop to true.

5.  Click OK to close.

6.  Open the first room and add 1 special moon. Run the game and music should play.

Now we will make 2 rockets.

Creating the landed rocket object:

1.  Create a new object called object_landed and give it the landed rocket sprite. Set the Depth to -10 so it appears in front of the moons and looks like it’s sitting on the surface of the special moon.

2.  Add a Step, End Step event. We will be adding events within these steps.

3.  Include a Jump to Position action. In the X value, type object_specialmoon.x and in the Y value object_specialmoon.y These names must be typed exactly or they will not work.

4.  Test the game by placing one instance of the rocked into the room. The rocket should jump onto the special moon.

When running the game you will notice the rocket continually spins around. This is because of the multiple images of the rocket. We will now work on controlling the rocket’s movements by dividing the movements into 5 degree increments (360/72=5)

Including a change sprite action in the landed object:

1.  In the landed rocket object properties form, include a Change Sprite action (main1) in its End Step event. Choose the landed sprite and type direction/5 in Subimage. Direction tells game Maker to recognize the direction a sprite is facing. Set Speed to 0 to stop the sprite from animating on its own.

Including keyboard events for the landed rocket object:

1.  Add a keyboard event,<left> event to landed rocket.

2.  Include a Move Free action and type direction+10 in the Direction property. Set Speed to 0.

3.  Add a similar Keyboard event for the <right> key. Include a Move Free action and type direction-10 in the Direction property.

Creating a flying rocket object:

1.  Create a new object called object_flying and select flying rocket sprite. Set Depth to -10 to make sure the object is in front of the moons.

2.  Add an Other, Outside Room event and include Wrap Screen in both directions.

3.  Add an End Step event. Include a Change Sprite action, choose flying rocket sprite, type direction/5 in Subimage and set Speed to 0.

4.  Add a Keyboard, <left> event and Move Free action. Type direction+2 in Direction and set Speed to 6.

5.  Add a Keyboard, <right> event with a Move Free action. Type direction-2 in Direction and Speed to 6.

Adding Collision events to the flying rocket object:

1.  Add a Collision event with the asteroid object and include Restart Game (main2) in the actions list.

2.  Add a Collision event with the moon object and include Change Instance action (main1). Set the object to change into object_landed and leave the other options as they are.

3.  Include a 2nd Change Instance action for changing the moon to the special moon. To make this happen, switch the Applies to from Self to Other. Set the change into object_specialmoon.

Adding a key press event to the landed rocket object:

1.  Open the object properties for the landed rocket.

2.  Add a Key press, <space> event and include Move Free. Type direction in the Direction property and set Speed to 6.

3.  Now include a Change instance and change object to object_flying.

4.  Include a Destroy action and change Applies to Object. Choose object_specialmoon.

Now we will move into working with scoring and winning or losing the game.

We will be adding an explosion object which when a rocket hits the asteroid, the explosion sounds and the game ends. Then the high score table will be displayed.

Adding an explosion object to the game:

1.  Create a new object called object_explosion and select the explosion sprite. Make the Depth -10 so it appears in front of the other instances.

2.  Add a Create event and include Play Sound (main1) for the explosion sound.

3.  Add an Other, Animation end event. This will run when the sprite reaches the final subimage in its animation.

4.  Include Show Highscore (score tab). To make it look more interesting, set Background to same as the game, set Other Color to Yellow and choose your font.

5.  Include a Restart Game to start the game again (main 2)

6.  Click OK to close.

Editing the Flying rocket object:

1.  Reopen the flying rocket

2.  Select Collision. Click on Restart Game and press Delete to remove it.

3.  Include a Create Instance action (main 1) and set to create explosion object. Make sure Relative is enabled.

4.  Include a Destroy Instance (main 1) and leave it to SELF so rocket is destroyed. Click OK.

Scoring will be set so that players cannot cheat and get unearned high scores. If you stay too long on a moon, you will be penalized.

Editing game objects to include scoring:

1.  Reopen special moon object and select Game Start event. Include a Set Score with a New Score of 1000. Close the form.

2.  Reopen the landed rocket form. Select End Step. Include a Set Score and New Score as -1 with Relative enabled. If players stay on the moon too long, they lose 1 point for each second they sit there. Close form.

3.  Reopen flying rocket form and select Collision event with moon. Include a Set Score and New Score of 500 with Relative enabled.

4.  Include a Play Sound action after setting the score and select the bonus sound.

Levels

To make this game more interesting, there are different levels for the player to go to after all of the moons are destroyed in the first level. We will be making 2 more levels so there will be a total of 3. Reminder—the order of levels played are based on the order they are named. You can change that order by dragging the one you want to be next above the one to be occurring last.

Creating more levels for the game:

1.  Right click the room in the resource list and choose Duplicate.

2.  Go to the settings tab and give the room a logical name (ie. room_second)

3.  Switch to the objects tab and add or remove instances.

4.  Make sure each level contains only 1 special moon and one landed rocket.

To move to the next room, we will have to use conditional logic. Game Maker needs to answer “is the total number of remaining moons equal to zero?” If yes (true), then the block of actions are performed and the player will move to the next room, if no (false) then the block of actions will not be performed. We will check this in the collision event with the flying rocket and the moon.

Editing the flying rocket to test for the number of remaining moons:

1.  Reopen the flying rocket and select Collision with the moon object.

2.  At the end of the list of actions, include a Test Instance Count (control tab). Set the Object to object_moon and the other settings will be the default.

3.  Below this action start a block. A block is a number of actions grouped together as part of a conditional action. All actions in the block will be performed if the condition is true and none if it is false. Add a Start Block action (control) below the condition to test the instances.

4.  Include a Sleep action (main2) and set Milliseconds to 1000. Sleep will equal 1 second.

5.  Now we award a player 1000 points when they finish the level. Include a Set Score (score) with a New Score of 1000 and Relative is enabled.

6.  Include a Next Room action from Main 1 to move to the next room.

7.  Add the End Block action (control) to end the conditional actions.

Finishing Touches.. we will add an opening title screen, a help screen and Congratulatory message when the game is completed.