Game Maker - Tutorial 5 - Lazarus

24
Game Prototyping: Game Maker tutorial 5   Page 1 Game Prototyping: Game Maker Tutorial 5: Lazarus **All sprites/objects/backgrounds/sounds/must contain your initials in the game!! Create your folder L5Lararus_ lastname import the directions, graphics and sounds The objectives from Lazarus includes:  Character animation by creating different objects and by switching sprites  Use a controller object to manage a game  Use else actions to provide more control over the outcome of the conditional actions Take notes on the game and the event button used. From the objectives above, discover the answers as  you design the game . First, write w hat is the game about. This all written work in your NOTEBOOK Summarize the game: in your own words Name all the sprites used in the game: 1. 2. Name all the objects used in the game: 1 2 Define major terms at the top of your notes as you go: List of the starting words Sprite: Object: Smooth Edges Set up the game: Game Infor mation Company Name Owner and programmer LAZARUS  Lazarus has been abduct ed by the Blob Mob, who are intent on bringing this harmless creature to a sticky end. They have imprisoned him at the Blob father's (sorry) factory, where they are trying to squish him under a pile of heavy boxes. However, they have not accounted for Lazarus' quick thinking, as the boxes can be used to build a stairway up to the power button that halts the machiner y. Do you have the reactions needed to help Lazarus build a way up, or will the evil mob claim one more innocent victim? Here’s a typical level taking shape in Lazarus .

Transcript of Game Maker - Tutorial 5 - Lazarus

8/16/2019 Game Maker - Tutorial 5 - Lazarus

http://slidepdf.com/reader/full/game-maker-tutorial-5-lazarus 1/24

Game Prototyping: Game Maker tutorial 5  – Page 1

Game Prototyping: Game MakerTutorial 5: Lazarus**All sprites/objects/backgrounds/sounds/must contain your initials in thegame!!

Create your folder L5Lararus_ lastnameimport the directions, graphics and sounds

The objectives from Lazarus includes:  Character animation by creating different objects and by switching sprites  Use a controller object to manage a game  Use else actions to provide more control over the

outcome of the conditional actions

Take notes on the game and the event button used.From the objectives above, discover the answers as you design the game. First, write what is the gameabout. This all written work in your NOTEBOOK

Summarize the game: in your own words

Name all the sprites used in the game:1.2.

Name all the objects used in the game:

12

Define major terms at the top of your notes as you go:

List of the starting wordsSprite:Object:Smooth Edges

Set up the game: Game Information

Company NameOwner and programmer

LAZARUS 

 Lazarus has been abducted by the Blob Mob, who are intent on bringing this harmless creature to asticky end. They have imprisoned him at the Blob father's (sorry) factory, where they are trying tosquish him under a pile of heavy boxes. However, they have not accounted for Lazarus' quickthinking, as the boxes can be used to build a stairway up to the power button that halts themachinery. Do you have the reactions needed to help Lazarus build a way up, or will the evil mobclaim one more innocent victim?

Here’s a typical level taking shape in Lazarus.

8/16/2019 Game Maker - Tutorial 5 - Lazarus

http://slidepdf.com/reader/full/game-maker-tutorial-5-lazarus 2/24

Game Prototyping: Game Maker tutorial 5  – Page 2

Controls <Left> Move or jump to the left<Right> Move or jump to the right<F4> Switch between windowed and full screen mode<Esc> End the game

Credits:Programming:[Your name here]

Graphics: Kevin Crossley

Music and Sound: Jacob Habgood

Original Concept: Jacob Habgood

The important lessons from this tutorial include using animated characters – both by creatingdifferent Objects and switching Sprites. You will also learn how the Else Action provides extracontrol over the outcome of Conditional Actions. Finally, you’ll get some much-needed practiceusing a Controller Object for storing Game Rules outside of the game’s playing pieces. 

In Lazarus, the player is a cute little blob who has been abducted by the Blob Mob and sent to theBlobfather’s factory to meet an untimely end squished under packing boxes. However, the boxescan for ‘stairs’ of escape for our hero, but knowing which boxes squishother boxes is part of thechallenge of the game.

Our hero can only jump left and right, and only as high as one box. New boxes appear directlyabove his head and fall down, so Lazarus has to keep moving at all times or be squished. There arefour types of boxes, increasing in weight and strength (cardboard, wood, metal, and stone). Aseach falls, it will crush all of the weaker boxes beneath it, so the situation in the Room is constantlychanging. While the next type of box is chosen at random, it will be shown to the player so thatstrategizing about where that box should fall becomes part of the gameplay excitement.

I. Building the Sprite assets for an animated character

To give Lazarus his cute / comical animations will require several different Sprites and Objects,each for a particular behavior that we want during play. Using multiple Objects helps toseparate the different animations for Lazarus in a simple way.

Note that all of the animations have been designed around the size of the boxes in the game,each of which is 40 x 40 pixels. So the size of the animated Sprites showing Lazarus jumping upand to either side must be 80 x 80 pixels to give him room to jump up and over. This means we’ll have to watch carefully where the Origin Point is for each animation to make sure that they

8/16/2019 Game Maker - Tutorial 5 - Lazarus

http://slidepdf.com/reader/full/game-maker-tutorial-5-lazarus 3/24

Game Prototyping: Game Maker tutorial 5  – Page 3

‘line up’ correctly during gameplay. Game Maker acts as if it holding each Sprite by its OriginPoint as it moves around the screen; so all the Origin Points need to be at the same positionrelative to Lazarus – regardless of the size of the Sprite! This will make sense as you create theLazarus resources.

 A.  We’ll start by creating the Sprite resources for Lazarus. 

1. Create spr_laz_stand (you must also include your initials in the sprite ex. I wouldname my sprite spr_laz_stand_mc)using the appropriate artwork from the files for thisgame. Give him Smooth edges. This is our ‘default’ look for ourhero.

Note that his Sprite is 40 x 40 with the Origin Point at the top-leftcorner (x:0, y:0). You’ll soon see why that’s important as we line up

other Sprites.

2. Create spr_laz_right using the lazarus_right.gif file and give it Ingame maker 8. Which is different then 7 Smooth edges. From when you first load the graphic, the smoothing check box is righthand side. This Sprite, you’ll notice, is 80 x 80 pixels and itsanimation shows Lazarus jumping 40 pixels to the right (you can press the blue arrow  button to preview the animation one frame at a time).

 As usual, the Origin Point has defaulted to the top-left corner of the Sprite (0,0). But thetop-left corner of this Sprite is further above Lazarus’ head than the previous one. To getthem to match up correctly, we need to move the Origin Point on this Sprite down by 40pixels – so set the ‘y’ value to ’40’ as shown above. Now it’s halfway down the left side. 

3. Create spr_laz_jump_right  in exactly the same way, but using the jump rightanimation file. Again, use Smooth edges and set the Origin Point’s ‘y’ value to ’40.’ 

4. Now go left. Create spr_laz_left using the Lazarus_left.gif file and giving him Smoothedges.

This time, going left, Lazarus starts on the bottom-right side of the Sprite. This means weneed to move the Origin Point 40 pixels down and 40 pixels to the right to have it in the

Smooth Edges

s function isrticularly good forrites that animate orerwise move around.

makes their ‘edge’els semi-transparentthat they moreoothly blend in withbackground image,

king them appears pixilated andocky’ in the game. 

8/16/2019 Game Maker - Tutorial 5 - Lazarus

http://slidepdf.com/reader/full/game-maker-tutorial-5-lazarus 4/24

Game Prototyping: Game Maker tutorial 5  – Page 4

same relative location as it is in spr_laz_stand. Set ‘x’ and ‘y’ to ‘40’  as shown hereand reflect for a moment. Try to see how spr_laz_stand would fit overlaid in the bottom-right corner of this Sprite and how its Origin Point would line up in the exact samerelative spot on. Can you envision that? If so, that’s great and you’re getting one of the principle lessons of this tutorial. 

5. Create spr_laz_jump_left in exactly the same way, but using the jump left animationfile. Again, use Smooth edges and set the Origin Point’s ‘x’ and ‘y’ values to ’40.’ 

6. Create spr_laz_afraid using its graphic. Give it Smooth edges and, because thisSprite is 40 x 40 pixels, its default Origin Point of 0,0 is fine.

7. Finally, Create spr_laz_squished using its graphic. Give it Smooth edges and, likethe above Sprite, it is 40 x 40 pixels, so its default Origin Point of 0,0 is fine.

That’s it for the Sprites for Lazarus. Now we need to make his Objects! 

B. The main Object will be Lazarus in his normal standing position. This will be the Object thatcontains the bulk of his rules while the others will only be called into existence to play theiranimations and then turn back into the normal standing Lazarus Object.

This creates a chicken-and-egg problem in terms of making the Objects (like it did for therockets in Galactic Mail ). The ‘Normal Object’ needs Actions to turn it into the ‘AnimatedObject’ and vice- versa. So which do we create first? We’ll create the ‘shell’ of the Normal Objectfirst, design all of its Animation Objects second, then go back and complete the Normal Objectlast. Clever, huh?  

1. Create a new Object, obj_laz_stand and assigning him spr_laz_stand. Press OK  onthis empty shell of an Object, as we’ll be getting back to it ina big way.

2. Create obj_laz_right and assign it spr_laz_right. It needs an Other: AnimationEnd Event with the first Action being to Jump to a given position which is 40 pixelsto the right (x = ‘40’ and y = ‘0’) ‘Relative’ to where Lazarus was standing. The second Action after this jump to the right is to Change the instance back intoobj_laz_stand (and you do ‘not’ need to perform Events) as shown below: 

3. Next, create obj_laz_left and assign it spr_laz_left. It needs an Other: AnimationEnd Event with the first Action being to Jump to a given position which is 40 pixelsto the left this time (x = ‘-40’ and y = ‘0’) ‘Relative’ to where Lazarus was standing. The

8/16/2019 Game Maker - Tutorial 5 - Lazarus

http://slidepdf.com/reader/full/game-maker-tutorial-5-lazarus 5/24

Game Prototyping: Game Maker tutorial 5  – Page 5

Have you saved

your game lately?

second Action after this jump to the right is to Change the instance back intoobj_laz_stand (and ‘not’ perform Events). 

4. Then create obj_laz_jump_right  and assign it spr_laz_jump_right. It too needsan Other: Animation End Event with the first Action being to Jump to a givenposition  which is 40 pixels up and to the right (x = ‘40’ and y = ‘-40’) ‘Relative’ to

 where Lazarus was standing. The second Action after this jump to the right is toChangethe instance back into obj_laz_stand (‘not’ Events). 

5. It’s no surprise that you must also create obj_laz_jump_left and assign itspr_laz_jump_left. Give it an Other: Animation End Event with the first Action being to Jump to a given position which is 40 pixels up and to the left  this time (x = ‘-40’ and y = ‘-40’) ‘Relative’ to where Lazarus was standing. The second Action afterthis jump to the right is to Change the instance back into obj_laz_stand (‘not’Events).

6. And since we’re on a roll, create obj_laz_squished and assign it spr_laz_squished.

Once more, you need an Other: Animation End Event but the Actions are differentthis time. Now, when the animation has ended, the player isdead, so we’ll start with an Action to Display a message (thatalso pauses the game until the player clicks on the OK button)something like, “YOU’RE HISTORY!#Better luck next time.”(You can be more creative in your text message.) Note that

 putting the pound symbol (#) into the text creates a line-break on the display. Thesecond action is to simply Restart the current room using whatever transition effect you desire.

That’s all of the animations, now we need to get back to the main LazarusObject (obj_laz_stand) and put in the rules for moving left and right thatuse these Animation Objects. To figure out if Lazarus is stuck, must jump,

or simply moves in a direction, we’ll use the Conditional Collision Action to work thatout, as you’ll soon see… 

7. Open up obj_laz_stand and let’sstart operating to build the Actionson the right.

Create a Key Press <Right>Event and its first Action is to askIf there is a collision at aposition with x = ‘0’ and y = ‘8’

against ‘Only solid’ Objects thatare ‘Relative’ to Lazarus’ currentposition, as shown on the left.

In other words, we’re checking tosee if Lazarus is standing on something. That’s because wedon’t want him jumping around while he’s in mid-air! So, we begin by asking the question of obj_laz_stand, “Are youstanding on something?” If so, then do the next Action. 

We’re asking ifLazarus is

Saying “Yes” 

The perform events optioncontrols whether the Destroy Eveof the current Object and theCreate Event of the new Objectshould be performed (or “called” ithe parlance of programmers).

This usually isn’t necessary, soGame Maker does not call them bdefault, but in this case we want tperform Events. Not for anythingyou can see now, but this will beimportant later when we add soun

effects!

8/16/2019 Game Maker - Tutorial 5 - Lazarus

http://slidepdf.com/reader/full/game-maker-tutorial-5-lazarus 6/24

Game Prototyping: Game Maker tutorial 5  – Page 6

But the next Action we want done is a series of Actions, so we must put them all together ina Block so that they are performed together as a group. We need theStart of a block  ofcode triangle, followed by the first Action, which is to ask If a position is collisionfree to Lazarus’ immediate right (x = ‘40’ and y = ‘0’ against Only solid Objects‘Relative’ to Lazarus’ current position). If that’s true, then Lazarus should perform thenext Action, which is to Change the instance into ‘obj_laz_right’ and ‘ yes’ performEvents (and check out the sidebar, “Saying ‘Yes’”).

Next, place the Else Action from the control tab in here;  I’ll explain that in more detailin a just a moment. 

Then once again ask If a position is collision free that is up and to the right ofLazarus (x = ‘40’ and y = ‘-40’ against Only solid Objects ‘Relative’ to Lazarus’ currentposition). If that’s true, then Lazarus should perform the next Action, which is toChange the instance into ‘obj_laz_jump_right’ and ‘ yes’ perform Events. Finally,set the End of a block  of code to close

up this group of Actions so it looks like the illustration above.

Or ‘Else’ what? The Else Action is often used in conjunction with Conditional Actions(i.e., those Actions that ask a question). Alone, a Conditional Action only specifies whatshould take place if that condition is true (which is always the next Action or group of Actions if they are set in a Block). However, in combination withElse, you can specify adifferent Action (or group) to be performed if that same conditions is not true. This hasmany uses when making games.

In this particular situation, the above Actions read this way: Is there solid groundbeneath Lazarus’ feet? Yes. Then is there a free space to the right of Lazarus? No, there

is a box there. Okay, well, is there a free space on top of that box then? Yes. Then jumpon top of it. 

That’s just one possible outcome for this Event, of course. Technically, four differentpossibilities are covered here: 1) not moving when Lazarus is falling through the air; 2)moving horizontally to the right when no boxes are in the way; 3) jumping diagonally tothe right when a single box is in the way; and 4) being unable to move to the right at all when there is more than one box in the way.

Here’s how it reads to a programmer: If the position below has something solid in it,

What “Else?” 

Like the other Conditional Actions (i.e., the ones that ask a question), the Else Action can be used with or withoutBlocks following it. If Blocks are not used after the Else Action, then only the Action that immediately follows it isperformed.

8/16/2019 Game Maker - Tutorial 5 - Lazarus

http://slidepdf.com/reader/full/game-maker-tutorial-5-lazarus 7/24

Game Prototyping: Game Maker tutorial 5  – Page 7

then read the next sentence. If the position to the right is collision free, then change intoobj_laz_right; else, if the position diagonally right is collision free, then change intoobj_laz_jump_right. 

Make sure you really comprehend the above logic; this is a key lesson from thistutorial. 

Now let’s do the same thing to get Lazarus to jump to the left 

Create a Key Press <Left> Event and, again, the first Action is to ask If there is acollision at a position with x = ‘0’ and y = ‘8’ against ‘Only solid’ Objects that are‘Relative’ to Lazarus’ current position. This is to make sure Lazarus is standing on solidground. If that’s true then perform the next Action (or series of Actions in this case). 

Look to the left to see the actions

 Add the Start of a block  of code triangle,followed by the first Action, which is to ask If aposition is collision free to Lazarus’immediate left (x = ‘-40’ and y = ‘0’ againstOnly solid Objects ‘Relative’ to Lazarus’current position). If that’s true, then Lazarusshould perform the next Action, which is toChange the instance into ‘obj_laz_left’ and‘ yes’ perform Events. 

Then place the Else Action on the list. 

 After that, once again ask If a position is collision free that is up and to the left ofLazarus (x = ‘-40’ and y = ‘-40’ against Only solid Objects ‘Relative’ to Lazarus’current position). If that’s true, then Lazarus should perform the next Action, which is toChange the instance into ‘obj_laz_jump_left’ and ‘ yes’ perform Events. Finally, setthe End of a block  of code to close up this group of Actions so that it looks like themirror image of the preceding group for moving to the right.

STOP HERE and REVIEWShow Mrs MacLeod your notebook to be graded

8/16/2019 Game Maker - Tutorial 5 - Lazarus

http://slidepdf.com/reader/full/game-maker-tutorial-5-lazarus 8/24

Game Prototyping: Game Maker tutorial 5  – Page 8

 What goes up…  Although our Key Press Events prevent Lazarus from jumping from an aerial position, there iscurrently no mechanism to bring him down when he’s in mid air. We’ll introduce “gravity” in classduring Week 7 with The Platformer Game, but as you’ll discover with Game Maker, there is usuallymore than one way to accomplish anything. For now, we’re going to haveGame Maker check every

Step (i.e., we’ll use a Step Event) to see if Lazarus should be falling.

The tricky bit is determining how far he should fall each Step. While its easy to set an amount ofmovement down to determine how fast he falls, but our life will be easer if we set that speed to anumber that divides exactly into 40 (i.e., the height in pixels of the boxes that he’ll be jumpingfrom). Can you think why?

 Well, let’s imagine that you pick a number thatdoesn’t neatly divide into 40, like 12. During thefirst Step, Lazarus will have fallen 12 pixels, 24 pixels on the second Step, 36 pixels on the fourth,and then 48 pixels after four Steps. At no point has Lazarus fallenexactly 40 pixels which is exactlythe height of one box. At the end of the third Step he is 4 pixels too high (at 36) or he’ll be 8 pixels

too low at the end of the fourth Step (at 48). This means that he would end up his fall either floatinover above the boxes (4 pixels) of jammed inside of one (by 8 pixels). Using any number thatdivides exactly into 40 (i.e., 1, 2, 4, 5, 8, 10, 20 or 40) avoids this problem. We’ll choose a value of‘8’ because that produces a sensible-looking falling speed.

8/16/2019 Game Maker - Tutorial 5 - Lazarus

http://slidepdf.com/reader/full/game-maker-tutorial-5-lazarus 9/24

Game Prototyping: Game Maker tutorial 5  – Page 9

 Add a Step: Step Event to obj_laz_stand. For the first Action, ask If a position iscollision free in the same way you’ve been doing, with x = ‘0’ and y = ‘8’ against‘Only solid’ objects that are ‘Relative’ to this Object. In other words, let’s check to seeif there is nothing under Lazarus’ feet, and if that’s the case... 

For the second Action, simply Jump to a given position heading down at x = ‘0’ and y = ‘8’ (the value discussed above) ‘Relative’ to Lazarus’ current position asshown on the left.

C. You’ve done a lot of steps without being able to check them, so let’s testLazarus out. To do that, we need to create a Room and the wall Object that for thatroom. Since there are no falling boxes yet, we’ll just arbitrarily place some in stacks tothat we can try out movement in both directions.

1. Create a new Sprite called spr_wall using wall.gif. Disable theTransparent option since the walls need to appear completely solid. Remember,

when ‘Transparent’ is ‘on,’ every pix el in that Sprite that is the same color as thebottom-left pixel becomes ‘clear.’  

2. Create a new Object named obj_wall using spr_wall. Be sure to enable the ‘Solid’ option asshown to the left. We told Lazarus to check if he’sstanding on ‘Solid’ Object s only, so for every box in thegame, including this wall ‘box,’ we must check the ‘Solid’option! 

3. Create a new Room called room_test and provide aCaption for the room, such as “Lazarus,” in the settings tab as shown on the right.

Then look at the toolbar along the top of the Room Properties window and set boththe Snap X and Snap Y  to ’40’ as shown below. Because all of our boxes (includingthe wall ‘box’) are 40 x 40 pixels. Setting the grid to this size will help us to place themneatly into the Room when design the different levels. Note the change in the gridsquares. 

………………. 

Now switch to the objects tab and place obj_wall around the room as shown here. You want to arrange these wall boxes in such a way that they for a flat area and starsgoing left and right. Remember, you can hold down the <Shift> key to ‘paint’ anObject around the room making multiple copies. Add on instance of obj_laz_standto the Room and you’re ready to test it out. 

Check the movement of Lazarus in all possible directions and situations to make surethat he’s behaving properly. If something isn’t working, retrace your steps and makesure that you have everything correct.

8/16/2019 Game Maker - Tutorial 5 - Lazarus

http://slidepdf.com/reader/full/game-maker-tutorial-5-lazarus 10/24

Game Prototyping: Game Maker tutorial 5  – Page 10

II. Falling Boxes

Now we’ll make the other boxes that both threaten to squash the player and also provide themeans of escape. Once again, there are four types of falling boxes, from most to least heavy theyare: stone, metal, wood and cardboard. The next type of falling box is chosen at random but isindicated in a preview area (so that the player can strategize). Lighter boxes are crushed by

heavier boxes when they land in a stack.

Think for a moment: each box needs to change its behavior three times in the game: 1) when itfirst appears in the preview location; 2) when it falls down from the top of the screen and landseither on Lazarus or other boxes; and 3) when it finally forms a stationary obstacle for Lazarusto negotiate. As you may have surmised, that means we’ll be creating three different Objects foreach box, one for each type of behavior. The stationary boxes are easiest and we’ll start there. 

 A.  Sprites first

Create spr_box_stone and spr_box_card using their respective graphic files.

Important: you must disable the making opaque feature on these two Sprites as theyhave no transparent pixels.The create spr_box_metal and spr_box_wood using theirrespective graphic files. This time, leave the Transparent boxenabled as these two Sprites have a small amount oftransparency around their edges.

Your test level should look something like this.

8/16/2019 Game Maker - Tutorial 5 - Lazarus

http://slidepdf.com/reader/full/game-maker-tutorial-5-lazarus 11/24

Game Prototyping: Game Maker tutorial 5  – Page 11

B. Creating the stationary box Objects

Create a new Object called obj_box_stone and assign it the Sprite you just made for it.Check the Solid option so that it will be detected in our collision tests with Lazarus asshown on the right.

Then do the same for obj_box_metal, obj_box_wood, and obj_box_card makingsure that each is set to Solid.

That’s it for the stationary boxes! Next are the falling boxes that start at the top of the screenright above Lazarus’ horizontal position –  which means we’ll be using the ‘x’ variable forLazarus to tell us where to place this box. Once it starts falling, we’ll give it a speed of ‘5’ because A) that number, too, dividesexactly into 40 (and you remember why that’simportant, right?), and B) it is slightly slower than the speed at which Lazarus falls (and wedon’t want Lazarus squished in mid air!). When a box collides with a heavier box, it turnsinto a stationary box (as we created above); when it collides with a lighter box, it destroysthat box and continues to fall.

B.  Creating the first falling box Object (i.e. the falling stone box Create a new Object:

C.  obj_falling_stone and use spr_box_stone again and set this object to Solid.

 Add a Create Event  with the first Action being Jump to a givenposition where x =‘obj_laz_stand.x’(that is, whateverLazarus’ current ‘x’position is) and  y = ‘-40’ (which, as youknow) is 40 pixelsabove the top of thescreen) as shown here.The second Action forthis Create Event is to Start moving in a direction: click the ‘down arrow ’ and set thespeed to ‘5’ as we discussed above 

Then add a Collision Event with obj_laz_stand and

squish him with the Action Change the instance. Now, we’re not changing the instance of obj_falling_stone here. We’re changing the instance of ‘Other’ (in this case, that would be obj_laz_stand –  which is the ‘other’ party in thisCollision Event) into ‘obj_laz_squished’ and ‘ yes’ we want to perform events (which will come into play when we add sound effects). This is shown on the left.

8/16/2019 Game Maker - Tutorial 5 - Lazarus

http://slidepdf.com/reader/full/game-maker-tutorial-5-lazarus 12/24

Game Prototyping: Game Maker tutorial 5  – Page 12

Now to collide with the wall and the other

 Add a Collision Event with obj_wall. There are two logical Actionshere: First, Start moving in a direction

and have this object stop moving byselecting the Center Square and set theSpeed to ‘0.’ Second, Change the instance of itself into its stationary counterpart,obj_box_stone

. The stone box stops falling and turns into the stationary box – and since they use the same Sprite, the player will never see it happening! 

Right-click on that Event and Duplicate it. Make it a Collision Event withobj_box_stone. The two Actions are identical (i.e., it stops falling and becomesobj_box_stone).

Three boxes to go.

 Add a Collision Event withobj_box_metal. Since metal is lighter thanstone, this box must be crushed, so the only Action here is to Destroy the instance of‘Other.’ You can Duplicate that Event two more times.The falling stone box will also Destroy theinstance of ‘Other’ in a Collision Event  withobj_box_wood and obj_box_card asshown to the right.

 WRITE THIS IN YOUR NOTEBOOK  M ATERIAL  M ATERIAL(S) THAT IT

CRUSHES Stone Metal, Wood, and CardMetal  Wood and Card

 Wood Card

8/16/2019 Game Maker - Tutorial 5 - Lazarus

http://slidepdf.com/reader/full/game-maker-tutorial-5-lazarus 13/24

Game Prototyping: Game Maker tutorial 5  – Page 13

D.  Creating the other falling boxObjects.

No doubt you can sniff out a pattern here and, with a little logic, cancreate the other obj_falling_(box type) Objects. They’re similar, so you can Duplicate obj_falling_stone to make

each of the others, but they will be slightly different when theycollide with the different typesof boxes. When it collides with a box of its own type of stronger, you need to

make sure that it stops moving and changes into the stationary version of itself (i.e.,obj_box_[itself]), as shown on the right.

 When it collides with a box that is weaker than its own type, it must destroy the instance of‘Other’ as shown on the left.

To make sure you have it right as to what crushes what, a table has been provided here.

Go ahead now and Duplicate obj_falling_stone to make obj_falling_metal,obj_falling_wood, and obj_falling_card. Be sure to tweak their Collision Event Actions with other boxes as described above!

Now look what it takes to make a video game.! Sure, you’ve just completed 28 Events and 48 Actions, butthe beginning. Programmerstake months and months to write thousands of lines of code for a single game. it’s not easy  is it! 

Now to make the last set of box Objects – the one’s that will appear in the bottom-leftcorner to be previewed by the player. Allowing them to be previewed provides the player astrategic element in setting up Lazarus where he wants the next box to fall. With somequick thinking and reflects, the right row of boxes will be built-up or crushed throughplayer skill in manipulating where the next box falls. These Objects are simple to make, butagain, we need four of them – one for each type of box.

E. The final set of boxes (i.e., the ‘next’ boxes) 

Create a new Object called obj_next_stone and assign itspr_box_stone. Make sure that it set to Solid and then you’re

done. This is shown on the right.

Then create obj_next_metal, obj_next_wood, andobj_next_card in the same way, making sure they have theircorresponding Sprite and are Solid.

That’s it for the boxes! 

Card None

8/16/2019 Game Maker - Tutorial 5 - Lazarus

http://slidepdf.com/reader/full/game-maker-tutorial-5-lazarus 14/24

Game Prototyping: Game Maker tutorial 5  – Page 14

What is a“Controller Object?” 

It is an Object that usually has no Sprite (so it is, in effect, invisible) and simply holds rules for the gamethat aren’t assigned to its individual units. Create, Room Start, and Room End Events are common. 

When these rules (Events and Actions) are done, a copy of this Controller Object is placed in the Room.Object without Sprites appear as a blue dot () with a red question mark (?) in it – this lets you knowthat you can see it while you’re designing the level (i.e., Room) but that players won’t see it when they

play the game.

 What we need to do now is devise the Actions that will create these boxes randomly, show them in the‘next box’ area, then put them at the top of the screen. We’re going to create aController Object todo this. A Controller Object is just an invisible ‘box of rules’ that we put in a Room to make things ‘go.The Controller Object for this game will use a Step Event to continually check if there is a falling boxon the level. If there isn’t , then the pending box will turn into a falling box and a new pending box will

 be generated. This will keep the game moving until the player either escapes or is squished.

F. Creating the game’s Controller Object 

Create a new Object called obj_controller. Leave it without a Sprite!

8/16/2019 Game Maker - Tutorial 5 - Lazarus

http://slidepdf.com/reader/full/game-maker-tutorial-5-lazarus 15/24

Game Prototyping: Game Maker tutorial 5  – Page 15

Why Check on Lazarus Here?

You might think it odd that we need to check that there is astanding Lazarus Object as part of our queries for creatingnew boxes. This is because, in the Create Event for fallingboxes, we used the variable ‘obj_laz_stand.x’ variable to placethem in the correct position.

Game Maker can’t provide that Object’s ‘x’ position if it hasturned into an animation Object, as that would create an errormessage and crash the game.

To avoid this, we simply check to make sure that there’s astanding Lazarus instance before creating any new fallingboxes.

 Add a Step: Step Event and brace yourself. You’re about to build all of the Actions below: 

Create the first Action which asks If the number of instances is a value for obj_falling_stone  being ‘Equal to’ the number ‘0.’ This creates a condition that is true (and hence the next Action is performed) only if there are no falling stone blocks. 

Duplicate the above Action three times and make sure that each asks about one of the other threeobj_falling _[box type]s. So, only if there are no falling boxes around will we get down to the fifthquestion. 

Create the fifth question, If the number ofinstances is a value for obj_laz_stand being‘Equal to’ the number ‘1’ as shown above (seethe sidebar for details as to why you did this).Okay, we’ve asked and found out that there are

none of each type of falling box Objects, andthere is an instance of Lazarus standingaround. Now what?  

 We need to drop the next box first, then we’ll picka random new next box. All of this must

 be done in answer tothe last question, so we must put these Actions together in a Block of Code so that they are performedas a single Action.

First, you want the Start of a block  of code.

The first Action in that block is to Change the instance for Object: ‘obj_next_stone’ into‘obj_falling_stone’ and ‘ yes,’ you want to perform events as shown on the right.That is, ifobj_next_stone is in the view area, it’s going to change into obj_falling_stone which will makeobj_next_stone disappear from the view area (it has been transformed and so is no longer a visibleObject there) and start falling from the top of the screen (as you have instructed its new incarnationto do in the obj_falling_stone Create Event). 

Duplicate the above Action three times and make sure that each transforms its obj_next_[type]

8/16/2019 Game Maker - Tutorial 5 - Lazarus

http://slidepdf.com/reader/full/game-maker-tutorial-5-lazarus 16/24

Game Prototyping: Game Maker tutorial 5  – Page 16

into its obj_falling_[type]. By doing this, we’ve covered all ofthe possibilities for whatever type of obj_next_[type] box mightbe in the preview area. With all our bases covered, now we needto randomly generate a new ‘next’ type of box. 

The next Action is to Create an instance of random object (which is on the main1 tab). Select

the four different obj_next_[box type] Objects to choose from. Set the value of ‘x’ to ‘0’ and ‘y’ to‘440’ – this is not ‘Relative,’ by the way. By using that ‘absolute’ location for ‘x’ and ‘y,’ you’re previewing the boxes in the bottom (440 pixels down from the top along the ‘y’ axis)-left (0 pixels tothe right along the ‘x’ axis) corner of the screen. 

Finally, it is time for the End of a block  for this code.

This long list of Conditional Actions (asking “if” and only advancing to the next one when the answeris “true”) means that the block of Actions at the end of it will only be performed ifall of thoseConditional Actions are true. In other words, if there are no instances of obj_falling_stone, and noinstances of obj_falling_metal, and no instances of obj_falling_wood, and no instances of

obj_falling_card, and there is an instance of obj_laz_stand, then and only then will Game Makerdrop the preview box and create a new random box in the preview corner.

That’s it for now! Let’s test this baby out!!  SAVE AS LAZARUS 2.

G. Test driving your core gameplay mechanics

Reopen the text Room and remove all of the instances of obj_wall (by right-clicking onthem) so that all you have left is a pit floor (i.e., walls on both sides and a floor along the bottom).

Make sure that it has one instance of obj_laz_stand on the floor and one instance ofobj_controller somewhere in the room. Don’t forget the Controller Object as it containskey rules and mechanics for play! 

Run the game and observe the gameplay carefully. Make sure that the box that appears inthe preview area is actually the box that falls from the ceiling. Also, make sure that heavier boxes crush lighter ones and that Lazarus is squished appropriately. If there are anyproblems, go back and fix them – you should be able to figure them out by now.

8/16/2019 Game Maker - Tutorial 5 - Lazarus

http://slidepdf.com/reader/full/game-maker-tutorial-5-lazarus 17/24

Game Prototyping: Game Maker tutorial 5  – Page 17

III. Finishing touches

 Well, we need to establish the game’s victory conditions (i.e., create an exit for Lazarus that willstart the next level). Then there are sound effects, a background image, a splash screen, etc. We’ll even create a worried looking Lazarus for those dangerous situations.

These are the ‘value added’ items that help make a game prototype into a more compelling and‘finished’ game experience. 

 A. Lazarus in dire peril

There is an Sprite animation that we have created but not yet used, and that one showsLazarus when he’s afraid. We’ll show that when the situation is nigh hopeless and he knowsthat the end is near. Rather than making a new Object for this state, we’ll just change theSprite for the standing Lazarus when he’s “afraid” and change it back when he’s not. We cando this because “being afraid” doesn’t require any new or special Actions: that state hasexactly the same behavior as standing (it just looks different).

 We’ll control this animation with a Step Event and constantly check to make sure that we’re playing the correct Sprite for Lazarusdepending on his situation. We’ll use theCollision Check Action to see if Lazarus issurrounded on both sides by boxes piled uptwo or more higher on both sides – if so, he’safraid!

Open up obj_laz_stand and select his StepEvent. Add an Action asking If there is acollision at a position for the box onLazarus’ right at x = ’40,’ y = ‘0’ against‘Only solid’ objects that are ‘Relative’ toLazarus’ current location. 

Duplicate this Action three times, and each time ask about another box location next toLazarus. That is, one will have x = ‘40’ and y = ‘-40;’ the next will be x = ‘-40’ and y = ‘0;’and the last will be x = ‘-40’ and y = ‘-40’ as shown here. 

If all of those are true, then the next Action is to Change the sprite into ‘spr_laz_afraid’ with subimage ‘0’ and a speed of ‘1.’ 

 While this will make Lazarus look afraid when this situation occurs, it is not entirelyhopeless. After all, a heavy box on either side of Lazarus might crush things down and freeour hero. When this happens, we need to tell Lazarus to stop looking afraid. Although wecould include more Conditional Actions to check for this happening and change his Sprite back, there’s an easier way. We’ll just put in aChange the sprite Action at the top of thelist of Actions for this Event that will set him back to his normal look. In other words, we’llmake spr_laz_stand the default Sprite every step and only change it when all of thoseConditional Actions are true.

8/16/2019 Game Maker - Tutorial 5 - Lazarus

http://slidepdf.com/reader/full/game-maker-tutorial-5-lazarus 18/24

Game Prototyping: Game Maker tutorial 5  – Page 18

 While still in the Step Event, add another Change the sprite Action only this time makethe sprite ‘spr_laz_stand’ with subimage ‘0’ and a speed of ‘1.’ Move this Action to the very top of the list (you can drag it up and down until you land it in the right spot) as shown below.

 You might want to play the game now and test out this new functionality. While features likethis don’t change the gameplay, they do enhance the experience and make it moreentertaining.

B. The victory condition

 W e need to create a “Stop” button in the factory that halt the machinery so that the boxesstop dropping. All we’re really doing, however, is creating a devise that simply takes Lazarusto the next Room when Lazarus collides with it (much like the checkered flag we used inprevious tutorial lessons). When there are no more Rooms, we’ll show a completion messageand restart the game.

Create a new Sprite calledspr_button and use thecorresponding art.

Create a new Objectcalled obj_button andset its Depth to ‘10’ sothat it appears behindother Objects in the gameas shown here.

 Add a Collision Event with obj_laz_stand and begin by adding a Sleep

Drag this Action to the top of the list.

8/16/2019 Game Maker - Tutorial 5 - Lazarus

http://slidepdf.com/reader/full/game-maker-tutorial-5-lazarus 19/24

Game Prototyping: Game Maker tutorial 5  – Page 19

for a while Action, leaving it at the default 1000 milliseconds (i.e., one second) and leaveredraw set to ‘true.’  This will buy the player a brief pause to realize that they’ve finishedthat level. 

Next, go to the main1 tab and ask If the next room exists. If that’s true, you want toperform the next Action, which should be Go to next room with whatever transition effect

that you desire (none is fine). These two Actions combined mean “look before you leap.”  

Drop in the Else control. What this Action is saying is that “if there is not a next Room,then do the next Action.” And since there is more than one thing to do based on there notbeing a next Room, we’ll put those actions in a Block. 

 You need the Start of a block  of code Action, followed by the Display a message Action(on main2). The text should read: “CONGRATULATIONS!#You have escaped the factory!”or something like that. Remember, the pound symbol (#) works like the <Enter> key andstart a new line of text on the display. 

Then a Go to a different room Action is next. You only have one Room to select at themoment, so choose it. After you have several Rooms (levels) created, you’ll want to comeback and adjust this to either go a cheese screen Room that you create, or back to the first Room. 

Finally, you want the End of a block  of code. It should all look as it appears on theprevious page. Click OK  to close this Object; you’re done. 

This is out by adding an instance of obj_button to the top of either side of the Room. Goon; I’ll wait for you. 

C. Starting a level made smoother

Currently, boxes start falling on our hero the moment he enters a level. The player has notime to think or strategize. We’ll help the player out by adding a Starter Object that displaysthe title for a couple of seconds before changing itself into the Controller Object.

Create a new Sprite called spr_title and use the appropriate graphic file.

Create a new Object called obj_title and assign it the title Sprite.

 Add a Create Event and start it with a Sleep for a while Action. This time set it for‘2000’ milliseconds (i.e., 2 seconds). 

 After that 2 second wait, the next Action is toChange the instance to obj_controller. You do ‘not’ need to perform Events. 

8/16/2019 Game Maker - Tutorial 5 - Lazarus

http://slidepdf.com/reader/full/game-maker-tutorial-5-lazarus 20/24

Game Prototyping: Game Maker tutorial 5  – Page 20

Edit your test Room by removing the instance of obj_controller (with a right click) andreplacing it with an instance of obj_title instead.

 You’ll notice that the title image doesn’t appear before the first level starts; only during theintervening levels. This is because the obj_title’s Create Event occurs before the windowappears (thus it has already turned into obj_controller by the time the room starts). You can

fix that using an Alarm Action as we did in our 1945 tutorial in class today; if you did that, it would look like this:

D. Sounds

There are a lot of sound resources for this game and you should be able to handle the assetcreation and placement for these files.

Create snd_music (this one loops as it’s the background music; the others don’t as they aresound effects and only play once when called), snd_wall, snd_crush, snd_squished,snd_move, and snd_button.

Place them using the Play a sound Action as follows:

 A good place to start background music (snd_music) would be in a new Other: GameStart Event inside obj_controller as shown below.

 All of the obj_falling_[type] Objects’ Collision Events need to play either snd_wall whenit lands on something at least as strong as itself… 

8/16/2019 Game Maker - Tutorial 5 - Lazarus

http://slidepdf.com/reader/full/game-maker-tutorial-5-lazarus 21/24

Game Prototyping: Game Maker tutorial 5  – Page 21

…or snd_crush when it lands on something weaker than itself:

 Add a Create Event for obj_laz_squished to play its sound, snd_squished.

 And then do the same thing for each of the four Lazarus movement Objects, addingsnd_move as shown below for obj_laz_right.

Did you do all four of those? Okay, that leavesobj_button. Play snd_button at the very

 beginning of its Collision Event with obj_laz_stand as shown below:

8/16/2019 Game Maker - Tutorial 5 - Lazarus

http://slidepdf.com/reader/full/game-maker-tutorial-5-lazarus 22/24

Game Prototyping: Game Maker tutorial 5  – Page 22

Test the game and check out your new audio. If you don’t hear a sound when movingaround, check that you set the perform events to ‘ yes’ for the Change instance Actionsfor the Key Press Events of obj_laz_stand (as shown below). If you didn’t, thenGame Maker wn’t perform the Create Events that contain the sounds effects you just placed for moving.

 We should add a backdrop to the levels now plus some help text for the players.

E. A background

Create a new background called ‘ background’ and use the background.bmp file from the art assets for this tutorial.

Reopen the Room and on the properties form, select the backgrounds tab. On the pull-down menu halfway down theleft side, select the new background image.

E.  Levels

One thing you need to do for sure is to create more levels(Rooms) for your game. It should be pretty easy to create 5 or10 total levels without working up a sweat. You should start with shallow pits and buttons on each side to keep things fairlyeasy while players learn the game. As levels progress, you can

add difficulty by making the pits less shallow and less wide.Raising the floor of the pit gives the player less time to react tofalling boxes. And stationary boxes can even be placed instrategically detrimental locations. Boxes and buttons in mid-air can also add to the challenge.

8/16/2019 Game Maker - Tutorial 5 - Lazarus

http://slidepdf.com/reader/full/game-maker-tutorial-5-lazarus 23/24

Game Prototyping: Game Maker tutorial 5  – Page 23

One sure way to trip up players is to alter the speed of thegame. In each Room, there is a settings tab that defaults to 30Game Turns per second. You can decrease the number in theearly levels to make those Rooms easier and ratchet it up on

later Rooms to speed up the game and make those levelsharder and harder.

 When building new Rooms, you should create a generic emptyroom with the basic foundations in it (walls, floor, and aninstance of obj_starter) and Duplicate it to save yourselfsome time. After creating a few levels, you’ll want to find some playtesters to try them outand let you know how difficult they find them – games are usually much harder for playersthan the game’s designer (who knows all the ins and outs). Just as an author cannot be his

own editor, so a game designer cannot be his only playtester.

G. Cheat keys

To help with playtesting,programmer often add “cheatkeys” to allow the playtester tomove easily through thelevels, gain extra lives,experience points, items, andso forth. For this game, acouple of keys to move you back and forth between the levels would be very much in order.

Open up obj_controller and add a Key Press <N> Event. For its only Action, have it Goto next room. Then add a Key Press <P> Event and for its only Action have it Go toprevious room. In this way, can use the <N> key for ‘Next’ and <P> key for ‘Previous,’ yousee?

H. Game Information

Players will want some instructions when the press the <F1> key for Help. Open up theGame Information item at the bottom of the Asset List along the left side of the screen bydouble-clicking on it. Be sure to include: The title of the game, its backstory, using the

controls, the victory conditions, and credits (listing you as the programmer). Here’s asample:

8/16/2019 Game Maker - Tutorial 5 - Lazarus

http://slidepdf.com/reader/full/game-maker-tutorial-5-lazarus 24/24

Game Prototyping: Game Maker tutorial 5  – Page 24

LAZARUS 

 Lazarus has been abducted by the Blob Mob, who are intent on bringing this harmless creature to asticky end. They have imprisoned him at the Blobfather's (sorry) factory, where they are trying tosquish him under a pile of heavy boxes. However, they have not accounted for Lazarus' quickthinking, as the boxes can be used to build a stairway up to the power button that halts the

machinery. Do you have the reactions needed to help Lazarus build a way up, or will the evil mobclaim one more innocent victim?

Controls <Left> Move or jump to the left<Right> Move or jump to the right<F4> Switch between windowed and full screen mode<Esc> End the game

Credits:Programming:

[Your name here]

Graphics: Kevin Crossley

Music and Sound: Jacob Habgood

Original Concept: Jacob Habgood

Final Stage And you are done !!!!!!!

Create a splash screen at the beginning of the game (i.e., a new first Room featuringa full screen of art and the ability to Go to next room by pressing the <Space>

 bar.Create a cheese screen at the end of the game (i.e., a new last Room with a rewarding

image)

Extra Credit: Add a scoring system, perhaps based on time alive, or when an instance of each

obj_box_[name] is created (perhaps with more points for one type over theother) and a bonus when the escape button is reached and at the end of the game.Don’t forget the High Score Table! 

Maybe some bonuses can appear when boxes are crushed – one could transform allthe stationary boxes into stone boxes to ‘stabilize’ the environment (or cardboardboxes if you’re feeling evil)