game maker: platform game

35
Game Maker: Platform Game 1|Page TABLE OF CONTENTS LESSON 1 - BASIC PLATFORM .............................................................................................................................................................3 RESOURCE FILES ......................................................................................................................................................................................... 4 SPRITES .................................................................................................................................................................................................... 4 OBJECTS ................................................................................................................................................................................................... 5 EVENTS/ACTION SUMMARY ......................................................................................................................................................................... 5 EVENTS/ACTION SUMMARY ......................................................................................................................................................................... 7 LESSON 2 - ADDING BACKGROUNDS ..................................................................................................................................................8 RESOURCE FILES ......................................................................................................................................................................................... 8 SPRITES .................................................................................................................................................................................................... 8 OBJECTS ................................................................................................................................................................................................. 10 BACKGROUNDS & TILE SETS ....................................................................................................................................................................... 10 ROOMS .................................................................................................................................................................................................. 11 LESSON 3 - MONSTERS ..................................................................................................................................................................... 15 RESOURCE FILES ....................................................................................................................................................................................... 15 SPRITES .................................................................................................................................................................................................. 15 SOUNDS ................................................................................................................................................................................................. 16 OBJECTS ................................................................................................................................................................................................. 16 MONSTER COLLISIONS ............................................................................................................................................................................... 16 EVENTS/ACTION SUMMARY ....................................................................................................................................................................... 17 OTHER COLLISIONS ................................................................................................................................................................................... 18 MONSTER MOVEMENT.............................................................................................................................................................................. 19

Upload: others

Post on 11-Nov-2021

18 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Game Maker: Platform Game

Game Maker: Platform Game

1|P a g e

TABLE OF CONTENTS LESSON 1 - BASIC PLATFORM .............................................................................................................................................................3

RESOURCE FILES ......................................................................................................................................................................................... 4

SPRITES .................................................................................................................................................................................................... 4

OBJECTS ................................................................................................................................................................................................... 5

EVENTS/ACTION SUMMARY ......................................................................................................................................................................... 5

EVENTS/ACTION SUMMARY ......................................................................................................................................................................... 7

LESSON 2 - ADDING BACKGROUNDS ..................................................................................................................................................8

RESOURCE FILES ......................................................................................................................................................................................... 8

SPRITES .................................................................................................................................................................................................... 8

OBJECTS ................................................................................................................................................................................................. 10

BACKGROUNDS & TILE SETS ....................................................................................................................................................................... 10

ROOMS .................................................................................................................................................................................................. 11

LESSON 3 - MONSTERS ..................................................................................................................................................................... 15

RESOURCE FILES ....................................................................................................................................................................................... 15

SPRITES .................................................................................................................................................................................................. 15

SOUNDS ................................................................................................................................................................................................. 16

OBJECTS ................................................................................................................................................................................................. 16

MONSTER COLLISIONS ............................................................................................................................................................................... 16

EVENTS/ACTION SUMMARY ....................................................................................................................................................................... 17

OTHER COLLISIONS ................................................................................................................................................................................... 18

MONSTER MOVEMENT .............................................................................................................................................................................. 19

Page 2: Game Maker: Platform Game

Game Maker: Platform Game

2|P a g e

ROOMS .................................................................................................................................................................................................. 21

LESSON 4 - CLIMBING ....................................................................................................................................................................... 22

RESOURCE FILES ....................................................................................................................................................................................... 22

SPRITES .................................................................................................................................................................................................. 22

OBJECTS ................................................................................................................................................................................................. 22

CLIMBING LADDER .................................................................................................................................................................................... 23

RAMP..................................................................................................................................................................................................... 25

ROOMS .................................................................................................................................................................................................. 26

GAME VIEW - SCROLLING ........................................................................................................................................................................... 27

LESSON 5 - AMMUNITION & MOVING PLATFORMS ......................................................................................................................... 29

RESOURCE FILES ....................................................................................................................................................................................... 29

SPRITES - AMMUNITION ............................................................................................................................................................................. 29

OBJECTS ................................................................................................................................................................................................. 29

ROOMS .................................................................................................................................................................................................. 31

SPRITES – DISAPPEARING PLATFORMS .......................................................................................................................................................... 31

OBJECTS ................................................................................................................................................................................................. 32

ROOM .................................................................................................................................................................................................... 32

SCORE PANEL .......................................................................................................................................................................................... 33

SPRITES .................................................................................................................................................................................................. 33

OBJECTS - BONUS ................................................................................................................................................................................... 33

OBJECTS – GAME CONTROLLER ................................................................................................................................................................... 33

ROOM .................................................................................................................................................................................................... 35

EXTENSION .............................................................................................................................................................................................. 35

Page 3: Game Maker: Platform Game

Game Maker: Platform Game

3|P a g e

LESSON 1 - BASIC PLATFORM For this tutorial you are going to create a simple platform game and is based on an article written by Carl Gustafsson. Some popular examples of the platform game include Mario Bros and Sonic the Hedgehog.

The following are traits usually found in platform games:

• The world is usually viewed from the side • The player can sometimes fly, climb ladders and jump over obstacles • The player usually tries to avoid enemies/monsters that could cause it to lose energy or their life • There are multiple levels which get progressively more challenging as the player goes further • There is an overall goal (e.g. save a princess) which the player strives to accomplish

We will be building towards a more complex platform game but initially the lessons will be to establish a relatively basic platform game so that you can get the hang of some new GameMaker events and actions.

Page 4: Game Maker: Platform Game

Game Maker: Platform Game

4|P a g e

RESOURCE FILES

If you haven't done so already, you will need to copy the GameMaker folder from the S:\Computer Department\Computer Studies directory. The files required for this tutorial are located in the Lecture Resources/Resources 4.

SPRITES

1. Create a new Game Maker file (File>New) then save as platform1. Remember to save the file every few minutes.

2. You will need to add a number of sprites for this game. To do this right-click on the Sprites folder and select Insert Sprite.

3. Click on the Load Sprite button and select the ball.gif file. Type sprBall in the Name box and remove the background then click OK.

4. You will also need to create a sprite manually. Right-click the Sprites folder and select Insert Sprite.

5. Click the Edit Sprite button then double-click the sprite. This will take you into the Image Editor window.

6. Using the Fill Bucket select a black colour then click on the image. Resize the image so that it is 16 x 16 pixels. Click the close and save button twice then name the sprite sprBlock and ensure that the background has not been removed.

Page 5: Game Maker: Platform Game

Game Maker: Platform Game

5|P a g e

OBJECTS

7. Create objects for the two sprites created earlier and name them objBall and objBlock. Make objBlock solid. Ensure that objBall is not a solid, then using the table below, add the following events/actions for the objBall object.

Event Action List Action Settings

keyboard, <left> Control x: -4, y: 0, relative

Move

x: -4, y: 0, relative

keyboard, <right> Control

x: 4, y: 0, relative

Move x: 4, y: 0, relative

keyboard, <up> Control

x: 0, y: 1, relative

Move vert speed: -10

collision, objBlock Move direction: direction; maximum: 12

Move vert speed: 0

EVENTS/ACTION SUMMARY

The combination of events and actions will allow the ball to move left or right depending on whether or not there is an obstacle blocking its path.

8. Add a new room (right click Room folder>Insert Room) then click the settings tab and change the room size to a width of 640 and height of 480. Change both the snap X and snap Y values to 16.

Page 6: Game Maker: Platform Game

Game Maker: Platform Game

6|P a g e

9. Add the relevant objects shown in the image below...

10. Test the game by pressing F5. When you click the left or right arrow key the ball should move in the appropriate direction. When you click the up arrow the ball should move straight up without stopping. We clearly need to add some more events and actions to give the ball a more realistic trajectory. In other words, after jumping up, it will fall back down in the same way that gravity works on Earth.

Page 7: Game Maker: Platform Game

Game Maker: Platform Game

7|P a g e

11. Ensure that the objBall Properties window is active by double-clicking on it. Now add the following actions to the Step event.

Event Action List Action Settings

Step, step Control x: 0, y: 1, relative

Move

direction: 270, gravity: 0.5

Control

Move direction: 270, gravity: 0

Control

variable: vspeed, value: 12, operation: larger than

Control variable: vspeed, value: 12

EVENTS/ACTION SUMMARY

The Step event works by checking exactly what the objBall is doing at each moment during the game. The first two actions check that there isn't a solid object underneath the ball and then allows the ball to drop back to the ground using a gravity value of 0.5. Otherwise, gravity is set to zero. The last two actions prevent the vertical speed from exceeding 12. As can be seen from the diagram below, setting the direction to an angle of 270° ensures that the player moves down.

12. Save and test the game again to make sure it works correctly.

Page 8: Game Maker: Platform Game

Game Maker: Platform Game

8|P a g e

LESSON 2 - ADDING BACKGROUNDS This is a continuation of the platform game created in the last lesson. Open the platform1 file from lesson 1. Save the file as platform2.

RESOURCE FILES

The files needed for this tutorial are located in the Lecture Resources/Resources 4 directory in the Game Maker folder that was copied earlier.

SPRITES

The current platform game needs a little more refinement to make the interface look more attractive and professional. For example, the player (which is currently the ball) will be changed into something more meaningful like a person. The background is a little dull and will also require some major changes.

1. Two different sprites (one for when the player moves left and another when they move right) are needed. Add the following sprites:

File Name Remove Background

player_left.gif sprLeft Yes

player_right.gif sprRight Yes

Uncheck the Precision collision checking box and set the Bounding Box for both sprites to manual. This is to prevent the sprites from being caught in a wall or a ceiling as they are different sizes.

2. You will also need to create two more sprites manually. Because these sprites will be smaller versions of sprBlock, it would be easier to duplicate the sprite created in the last lesson. Right-click the sprBlock sprite and select Duplicate then type sprBlockH in the name box.

3. Click the Edit Sprite button and then double-click the image to edit the sprite...

Page 9: Game Maker: Platform Game

Game Maker: Platform Game

9|P a g e

...Select the Transform menu and choose Stretch. Uncheck the Keep aspect ratio box and change the height to 8 pixels then click OK. Set the Origin Y value to 8. Save and close the sprite.

4. Duplicate the sprBlock sprite again. Name the new sprite sprBlockV and modify the settings so that its width is 8 pixels and the height is 16 pixels.

Page 10: Game Maker: Platform Game

Game Maker: Platform Game

10|P a g e

OBJECTS

As mentioned earlier, the player will now take the shape of a person, and depending on whether they press the left or right arrow key, the player object will face left or right.

5. Select the objPlayer object and change the sprBall sprite to sprRight. Now add the following to the current list of events/actions that have been already applied to the objPlayer object. Ensure that they are the first actions for each keyboard event.

Event Action List Action Settings

Keyboard <left> Main1

sprite: sprLeft, subimage: 0, speed: 1

Keyboard <right> Main1

sprite: sprRight, subimage: 0, speed: 1

6. Create objects for sprBlockH (objBlockH) and sprBlockV (objBlockV) and set the parent to Block for both objects.

Ensure that the Visible property for all the blocks is unchecked. The reason for this is that the background tile that we will be adding to the game a little later will have its own 'objects' which need to be visible during gameplay.

BACKGROUNDS & TILE SETS

Two types of backgrounds will be used in the platform game. The first is a sky image that will appear behind all other images in the background. The second is a tile set that will be used to draw the different objects in the room.

A tile set is collection of smaller images called TILES (typically of uniform size) which have been combined into a single larger image. TILE SETS are often used in 2D video games to create complex maps from reusable TILES within the set. When a TILE SET based map is displayed, the TILES that are stored within it are used to reassemble the map for display. This technique is seen in games designed to run on portable systems such as Nintendo's Game Boy Advance system or a cellular phone. Using TILE SETS reduces the amount of system memory required to display maps since it allows for the same TILES to be reused multiple times in a map. It also reduces amount of artwork needed for individual maps since many different ones can be created

Page 11: Game Maker: Platform Game

Game Maker: Platform Game

11|P a g e

from the same TILESET . In order for maps made from TILE SETS to appear more distinctive, games typically display them with a different TILE SET for each unique environment.

(From: URL - ht tp: / /en.wikipedia.org/wiki/T i le_se t ; Accessed: 14 /10/08)

7. To add the sky background, right-click the Background folder and select Create Background. Click the Load Background button and select sky.gif (located in the GameMaker/Background folder). Change the name to bkdSky then save and close.

8. Repeat the above step and add the tiles.gif to the background. Check the Transparent and Use as tile set boxes and type 1 into the horizontal and vertical sep: boxes. Change the name to bkdTiles then save and close.

ROOMS

9. Double-click the room to edit the room then remove all the objects that were created in the last lesson. Click on the Tiles tab and select bkdTiles.

Page 12: Game Maker: Platform Game

Game Maker: Platform Game

12|P a g e

10. Click on the grey post in the top left corner of the tile set to select it then click in the different parts of the room to add it where needed.

11. Repeat this process by selecting the other objects in the tile set and place them where needed until the room looks like the example below.

12. To make the bkdSky visible, click the Backgrounds tab and modify the settings as shown below:

Page 13: Game Maker: Platform Game

Game Maker: Platform Game

13|P a g e

13. The tile set images although visible are not solid and won't allow the player to walk on the or collide with them. Click the Objects tab and cover the tiled images using the various blocks. The blocks if you recall have been made invisible but are solid, so the game will give the impression that the player is walking on the various images that have been placed from the tile set.

14. Repeat the above step until all tile elements are covered with blocks. For the smaller objects such as the cloud and platform edges, you will need to change the snap settings for the room to 8 x 8. By doing this, you can now add the block objects objBlockH and objBlockV to fill in the smaller sections.

Page 14: Game Maker: Platform Game

Game Maker: Platform Game

14|P a g e

15. Change the snap settings back to 16 x 16 then add the objPlayer object to the room as shown. Save and test the game. The player should be able to walk and jump along the platforms.

Page 15: Game Maker: Platform Game

Game Maker: Platform Game

15|P a g e

LESSON 3 - MONSTERS This is a continuation of the platform game created in the last lesson. Open the platform2 file from lesson 2. Save the file as platform3.

RESOURCE FILES

The files needed for this tutorial are located in the Lecture Resources/Resources 4 directory in the Game Maker folder that was copied earlier.

SPRITES

To help generate and maintain the player's interest more features need to be included in the game. For example, there might be some monsters that need to be avoided or some objects that can be collected that will increase the player's score.

1. Add the following sprites to the platform game:

File Name Remove Background

monster_1_left.gif sprMonsterL Yes

monster_1_right.gif sprMonsterR Yes

monster_1_flat.gif sprMonsterFlat Yes

monster_2_left.gif sprFlyingL Yes

monster_2_right.gif sprFlyingR Yes

mushrooms.gif sprMushroom Yes

levelexit.gif sprLevel Yes

Uncheck the Precision collision checking box and set the Bounding Box for all sprites to manual.

2. You will also need to create two more sprites from scratch. Duplicate sprBlock and name this sprite sprMarker then change the fill colour to blue. Duplicate sprBlockH and name this sprite sprDeath then change the colour to red.

Page 16: Game Maker: Platform Game

Game Maker: Platform Game

16|P a g e

SOUNDS

3. Add the following sounds to the platform game:

File Name

boing.wav monsterkill

ao.wav killplayer

ploup.wav getmushroom

harp.wav finishlevel

OBJECTS

4. Create objects for each of the new sprites using the image below as a guide:

MONSTER COLLISIONS

There are two types of monsters that the player will encounter - the walking monster and the flying monster. The way that the players reacts to each monster will also be different. For example, the player will be able to destroy the walking monster by jumping on top of it. All other collisions with other monsters will result in the player losing a life.

5. Add the following events/actions to objPlayer:

Page 17: Game Maker: Platform Game

Game Maker: Platform Game

17|P a g e

Event Action List Action Settings

collision, objMonster

Control vspeed> 0 and y < other.y+8

Control

Control

Main1 sound: killmonster

Score

score: 50, relative

Move no move, other

Main1

Applies to: other; Change into: objMonsterDead, perform events: yes

Control

Control

Control

Control

Main1

sound: killplayer

Main2 milliseconds: 1000

Main1 transition: fade out/in

Control

collision, objFlyer Main1 sound: killplayer

Main2 milliseconds: 1000

Main1 transition: fade out/in

EVENTS/ACTION SUMMARY

The first action is checking to see if the player is in the air and above the monster. If this condition is met, then the player will be able to destroy the monster. The actual sequence of events following the player jumping on top of the walking monster is as follows: Play sound of killing monster, Add 50 to score, Stop the monster from moving, Change the normal 'alive' monster sprite into the dead monster. For all other collisions with the monster, the player dies and the room is then restarted.

Page 18: Game Maker: Platform Game

Game Maker: Platform Game

18|P a g e

OTHER COLLISIONS

There are some other collisions that the player will encounter during the course of the game. They include:

• Mushroom - This will add points to the player's score and destroy the mushroom • Level Exit - This will proceed to a new room if it exists, otherwise it will display the high score table

and restart the game • Death - This will kill the player and restart the room

Another event (other, outside room) will check if the player has moved beyond the height of the room, and will result in the player losing a life and the room restarting.

6. Add the remaining events/actions to the objPlayer object:

Event Action List Action Settings collision, objMushroom Main1

sound: getmushroom

Score

score: 10, relative

Main1

destroy: other

collision, objLevelExit Main1 sound: finishlevel

Main1 milliseconds: 1000

Main1

Control

Main1

Control

Control

Control

Score background: bkdSky

Main2

Control

Page 19: Game Maker: Platform Game

Game Maker: Platform Game

19|P a g e

Event Action List Action Settings collision, objDeath Main1

sound: killplayer

Score

milliseconds: 1000

Score New lives: -1; relative Main1

other, outside room Control

variable: y, value: room_height, operation:

larger than Control Main1

sound: killplayer

Main1

Main1

milliseconds: 1000

Control

MONSTER MOVEMENT

Each of the monsters will follow a similar movement pattern during the game. The only difference is that one of the monster types will appear to be flying. Both monsters will move in a particular direction until they encounter either a block or a marker, after which they will reverse their direction. To take into account this direction switch, the monster sprite will change into either a left-facing or right-facing monster.

7. Add the following events/actions for objMonster:

Event Action List Action Settings Create Move

direction: right, speed: 4

Step, End Step Control variable: hspeed, value: 0, operation: larger than

Main1 sprite: sprMonsterR, speed: 1

Control

Main1 sprite: sprMonsterL, speed: 1

collision, objBlock Move

collision, objMarker Move

Page 20: Game Maker: Platform Game

Game Maker: Platform Game

20|P a g e

8. Add the following events/actions for objFlyer:

Event Action List Action Settings create Move

direction: right, speed: 3

step, end step Control

variable: hspeed, value: 0, operation: larger than

Main1

sprite: sprFlyingR, speed: 1

Control

Main1

sprite: sprFlyingL, speed: 1

collision, objBlock Move

collision, objMarker Move

The variable hspeed is used to determine the direction that the monster is travelling, and hence which sprite (left or right monster) it must change into. When hspeed is greater than 0, this means that the monster is moving from left to right.

9. Add the following events/actions for objMonsterDead:

Event Action List Action Settings create Main2

no. of steps: 10, in alarm

no: Alarm 0 alarm, alarm 0 Main1

self

9. Add the following events/actions for objMushroom:

Event Action List Action Settings create Main2

sprite: sprMushroom, subimage:

random(10), speed: 0

When the mushrooms are added to the game in the next step, they will all appear to look the same. However, by using the event/action created above, the game will change the appearance of the mushroom to one of ten possible sub-images available within this sprite.

Page 21: Game Maker: Platform Game

Game Maker: Platform Game

21|P a g e

ROOMS

10. The room will need to be modified to include the monsters, mushrooms, markers and the 'death pit'. Open the room and then select the Tiles tab. Replace the tile objects in the bottom right corner with the spikes shown in the image below:

11. Select the Objects tab and add the objects shown below. Save and test the game.

Page 22: Game Maker: Platform Game

Game Maker: Platform Game

22|P a g e

LESSON 4 - CLIMBING This is a continuation of the platform game created in the last lesson. Open the platform3 file from lesson 3. Save the file as platform4.

RESOURCE FILES

The files needed for this tutorial are located in the Lecture Resources/Resources 4 directory in the Game Maker folder that was copied earlier.

SPRITES

This version of the game will include the addition of features such as the player being able to climb vines and walk up and down ramps.

1. Add the following sprite to the platform game:

File Name Remove Background

player_up.gif sprClimbing Yes

Uncheck the Precision collision checking box and set the Bounding Box for all sprites to manual.

2. You will also need to create a new sprite. Duplicate sprBlockV and name this sprite sprLadder then change the backcolour to black and the fill colour to green. Make it transparent.

OBJECTS

3. Create the object objLadder using the sprite sprLadder and set visible to false.

Page 23: Game Maker: Platform Game

Game Maker: Platform Game

23|P a g e

CLIMBING LADDER

4. Modify the objPlayer by adding the new events/actions as shown below. The following sequence of actions will check whether the player has made contact with the ladder.

Event Action List Action Settings Step, step Control

Control

object: objLadder, x:0, y:0, relative

Control

Move direction: 270; gravity: 0

Control variable: vspeed; value: 0

Main1

sprite: sprClimbing; subimage: 0; speed: 1

Control

The complete set of actions for objPlayer step event should like the following:

Page 24: Game Maker: Platform Game

Game Maker: Platform Game

24|P a g e

The following sequence will actually move the player up and down the ladder if the player is in contact with it. Note that the settings for the collision at position and set vertical speed actions in the second block are the same as before.

Event Action List Action Settings Keyboard <up> Control

object: objLadder, x:0, y:0, relative

Control

Control

x:0, y:-3, objects: only solid, relative

Move x:0, y:-3, relative

Control

Control

Control

Control x:0, y:1, objects: only solid,

relative

Move vert speed: -10

Control

Keyboard <down> Control

object: objLadder, x:0, y:0, relative

Control

Control

x:0, y:3, objects: only solid, relative

Move x: 0, y:3, relative

Control

Page 25: Game Maker: Platform Game

Game Maker: Platform Game

25|P a g e

RAMP

The following actions will allow the player to move up the ramp. Note, the first sequence of actions have not changed and will allow the player to continue moving left or right as well as moving down the ramp.

Event Action List Action Settings Keyboard <left> Main1

sprite: sprLeft, speed: 1

Control

x:-4, y:0, objects:only solid, relative

Move x:-4, y:0, relative

Control

Control

x:-4, y:-8, objects: only solid, relative

Control

Move x:-4, y:-8, relative

Move

direction: 270, maximum: 8, against: solid objects

Control

Keyboard <right> Main1 sprite: sprRight, speed: 1

Control

x:4, y:0, objects:only solid, relative

Move x:4, y:0, relative

Control

Control

x:4, y:-8, objects: only solid, relative

Control

Move x:4, y:-8, relative

Move

direction: 270, maximum: 8, against: solid objects

Control

Page 26: Game Maker: Platform Game

Game Maker: Platform Game

26|P a g e

ROOMS

5. Using the vine image from the tile set as well as the objLadder object that was created earlier, add the vines and ladder to the room as shown below. Add a ramp to the room using the example below as a guide.

Page 27: Game Maker: Platform Game

Game Maker: Platform Game

27|P a g e

GAME VIEW - SCROLLING

At present the entire room is visible when you play the game. A typical scrolling platform game displays only a portion of the screen at any given time and this view will depend on where the player is located. In other words, the game will follow the player's movements across the screen.

6. Open the room then click the View tab. Check the Enable the use of Views and the Visible when room starts boxes.

7. Enter 300 for W and 200 for H in both the View in room and Port on screen sections. This sets the dimensions of the view that will be seen at any given time.

8. Select objPlayer from the Object following section and enter 64 for both Hbor and Vbor. Type 4 for both Hsp and Vsp. The Hbor and Vbor values determine how close the player can get to the view's border before the game starts scrolling. The Hsp and Vsp is the scrolling speed. The higher this value is the faster the scrolling speed.

Page 28: Game Maker: Platform Game

Game Maker: Platform Game

28|P a g e

9. Save and test the game. The scrolling feature should work but the size of the actual game is a little small.

10. Double-click the Global Game Settings and change the Fixed scale value to 200% as shown. This will double the size of the room and all of its objects. Save and test the game.

Page 29: Game Maker: Platform Game

Game Maker: Platform Game

29|P a g e

LESSON 5 - AMMUNITION & MOVING PLATFORMS This is a continuation of the platform game created in the last lesson. Open the platform4 file from lesson 4. Save the file as platform5.

RESOURCE FILES

The files needed for this tutorial are located in the Lecture Resources/Resources 4 directory in the Game Maker folder that was copied earlier. For the final version of the platform game, the following new features will be added:

• The player will be able to collect ammunition and shoot the monsters. • There will be moving platforms as well as platforms that disappear when the player jumps on them.

SPRITES - AMMUNITION

1. Add the following sprites to the platform game:

File Name Remove Background

bullet.gif sprBullet Yes

ammunition.gif sprAmmunition Yes

OBJECTS

2. Create objects objBullet and objAmmunition using the sprites created in the previous step.

3. When the game first starts, the player will have no ammunition to shoot. It is only when the player collects the ammunition object that it will then have the capability to fire bullets at the monster. Modify the objPlayer by adding the new events/actions as shown below:

Event Action List Action Settings Create Control

variable: ammo, value: 0

collision, objAmmunition Control

variable: ammo, value: 10, relative

Main1

destroy: other

Page 30: Game Maker: Platform Game

Game Maker: Platform Game

30|P a g e

Once the player has collected the ammunition, he will then be able to fire bullets at the monsters. The following sequence of events and actions will give the player the ability to shoot using the space bar:

Event Action List Action Settings Key press <space> Control

variable: ammo, value:0, operation: larger than

Control

Control

variable: sprite_index, value: sprLeft, operation: equal to

Main1

object: objBullet, x:0, y:0, speed:12, direction:180, relative

Control

variable: sprite_index, value: sprRight, operation: equal to

Main1

object: objBullet, x:0, y:0, speed:12, direction:0, relative

Control

variable: ammo, value: -1, relative

Control

4. The next sequence of events/actions will deal with the bullets being fired from the player's gun. Add the following events/actions to the objBullet object:

Event Action List Action Settings collision, objBlock

destroy: self

collision, objMonster Control

sound: killmonster

Control

new score:50, relative

Control

destroy: other

Main1

destroy: self

collision, objFlyer Control

sound: killmonster

Main1

new score:50, relative

Control

destroy: other

Control

destroy: self

other, outside room

destroy: self

Page 31: Game Maker: Platform Game

Game Maker: Platform Game

31|P a g e

The events/actions created in this step will produce the following result:

• Collision with objBlock - This will destroy the bullet when it hits any of the walls, platforms, etc. • Collision with objMonster and objFlyer - This will destroy the monster as well as the bullet and add 50

to the score (as well as play the killmonster sound). • Outside room - This will destroy the bullet as soon as it leaves the room.

ROOMS

5. Open the room and place the objAmmunition object anywhere in the room. Save and test the game. When the player collects the ammunition, they should be able to fire at and kill the monsters in the room.

SPRITES – DISAPPEARING PLATFORMS

The new platform that you will be creating will be visible and solid to begin with, but as soon as the player makes contact with it, it will slowly disappear, causing the player to then fall.

6. Add the following sprite to the platform game:

File Name Remove Background

fallingblock.gif sprFallingBlock Yes

7. This sprite needs to be made into an animated gif where it will start as a solid object then slowly fade away. Click the Edit Sprite button.

8. Click the Animation menu and select Disappear. Type 5 for the number of frames.

9. Ensure that the Remove Background option is selected then click OK.

Page 32: Game Maker: Platform Game

Game Maker: Platform Game

32|P a g e

OBJECTS

10. Create an object for the falling block sprite created earlier and name it objFallingBlock. The falling block will have the following properties:

• It will be solid in its initial state. • When the player lands on the block it will slowly fade until it disappears. • When the block has completely disappeared, the player will fall.

11. Create the following events/actions for the objFallingBlock object:

Event Action List Action Settings Create Control

variable: image_single;

value: 0

Step, step Control object: objPlayer; x: 0; y: -2; relative

Control

variable:image_single; value: 0

Control

variable: image_single; value: -1

Animation, end Main1 self

ROOM

12. Modify the room to include the falling blocks in the bottom right corner (just above the pit) as shown below:

8. Save and test the game.

Page 33: Game Maker: Platform Game

Game Maker: Platform Game

33|P a g e

SCORE PANEL

Another useful feature found in most games is some type of scoring panel. As well as tracking the player's score during the game, it also can be used to display how many lives they have or the number of weapons they have at their disposal. The platform game will also give the user an opportunity to gain an extra life.

SPRITES

9. Add the following sprite to the platform game:

File Name Remove Background

heart.gif sprBonus Yes

OBJECTS - BONUS

10. Create the object objBonus using the sprite sprBonus created in the last step.

11. Modify the objPlayer by adding the new events/actions as shown below:

Event Action List Action Settings Collision, sprBonus Control sound: finishlevel loop: false

Control new lives: 1 relative

Main1 self

OBJECTS – GAME CONTROLLER

A new object will be needed to control and display the scoreboard. Note: You will not need to create a sprite for this object as it won’t be visible during the game.

12. Create a new object called objLifeController.

13. Create the following events/actions for the objLifeController object:

Page 34: Game Maker: Platform Game

Game Maker: Platform Game

34|P a g e

Event Action List Action Settings Other, Game start Score new lives: 3

Score

score caption: score lives caption: lives;

health caption: health

Other, No more lives Score background: sky border: show

Main2

Draw Draw color: green

Draw

x1: view_xview + 5 y1: view_yview + 1

x2: view_xview + 100 y2: view_yview + 45

filled: filled

Draw color: black

Draw

x1: view_xview + 5 y1: view_yview + 1

x2: view_xview + 100 y2: view_yview + 45

filled: outline

Score

x: view_xview+10 y: view_yview+10

image: sprLife Score

x: view_xview+10 y: view_yview+28

score: Score Control

variable: objPlayer.ammo

value: 0; operation: larger than

Main1 x: view_xview+70 y: iew_yview+2

subimage: 0

Page 35: Game Maker: Platform Game

Game Maker: Platform Game

35|P a g e

ROOM

14. Modify the room to include the objLifeController as shown below. Save then test the game.

EXTENSION

Create some more additional rooms with extra challenges to make the game more interesting.