Game Prototyping: Game Maker Tutorial 5: Lazarus Prototyping: Game Maker tutorial 5 – Page 1 Game...

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 what 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 Information Company Name Owner and programmer LAZARUS Lazarus has been abducted 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 machinery. 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 Prototyping: Game Maker Tutorial 5: Lazarus Prototyping: Game Maker tutorial 5 – Page 1 Game...

Page 1: Game Prototyping: Game Maker Tutorial 5: Lazarus Prototyping: Game Maker tutorial 5 – Page 1 Game Prototyping: Game Maker Tutorial 5: Lazarus ...  End the game Credits:

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 what 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 Information

Company Name Owner and programmer LAZARUS

Lazarus has been abducted 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 machinery. 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.

Page 2: Game Prototyping: Game Maker Tutorial 5: Lazarus Prototyping: Game Maker tutorial 5 – Page 1 Game Prototyping: Game Maker Tutorial 5: Lazarus ...  End the game Credits:

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 creating different Objects and switching Sprites. You will also learn how the Else Action provides extra control over the outcome of Conditional Actions. Finally, you’ll get some much-needed practice using 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 the Blobfather’s factory to meet an untimely end squished under packing boxes. However, the boxes can for ‘stairs’ of escape for our hero, but knowing which boxes squish other boxes is part of the challenge of the game. Our hero can only jump left and right, and only as high as one box. New boxes appear directly above his head and fall down, so Lazarus has to keep moving at all times or be squished. There are four types of boxes, increasing in weight and strength (cardboard, wood, metal, and stone). As each falls, it will crush all of the weaker boxes beneath it, so the situation in the Room is constantly changing. While the next type of box is chosen at random, it will be shown to the player so that strategizing 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 to separate 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 up and 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

Page 3: Game Prototyping: Game Maker Tutorial 5: Lazarus Prototyping: Game Maker tutorial 5 – Page 1 Game Prototyping: Game Maker Tutorial 5: Lazarus ...  End the game Credits:

Game Prototyping: Game Maker tutorial 5 – Page 3

‘line up’ correctly during gameplay. Game Maker acts as if it holding each Sprite by its Origin Point as it moves around the screen; so all the Origin Points need to be at the same position relative to Lazarus – regardless of the size of the Sprite! This will make sense as you create the Lazarus 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 would name my sprite spr_laz_stand_mc)using the appropriate artwork from the files for this game. Give him Smooth edges. This is our ‘default’ look for our hero. Note that his Sprite is 40 x 40 with the Origin Point at the top-left corner (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 In

game maker 8. Which is different then 7 Smooth edges. From when you first load the graphic, the smoothing check box is right hand side. This Sprite, you’ll notice, is 80 x 80 pixels and its animation 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 the top-left corner of this Sprite is further above Lazarus’ head than the previous one. To get them to match up correctly, we need to move the Origin Point on this Sprite down by 40 pixels – 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 right

animation 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 Smooth

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

Smooth Edges

This function is particularly good for Sprites that animate or otherwise move around. It makes their ‘edge’ pixels semi-transparent so that they more smoothly blend in with the background image, making them appear less pixilated and

‘blocky’ in the game.

Page 4: Game Prototyping: Game Maker Tutorial 5: Lazarus Prototyping: Game Maker tutorial 5 – Page 1 Game Prototyping: Game Maker Tutorial 5: Lazarus ...  End the game Credits:

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 here and 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 same relative 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 animation

file. 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 this

Sprite 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, like

the 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 that contains the bulk of his rules while the others will only be called into existence to play their animations 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 the rockets in Galactic Mail). The ‘Normal Object’ needs Actions to turn it into the ‘Animated Object’ and vice-versa. So which do we create first? We’ll create the ‘shell’ of the Normal Object first, design all of its Animation Objects second, then go back and complete the Normal Object last. Clever, huh?

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

2. Create obj_laz_right and assign it spr_laz_right. It needs an Other: Animation

End Event with the first Action being to Jump to a given position which is 40 pixels to 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 into obj_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: Animation

End Event with the first Action being to Jump to a given position which is 40 pixels to the left this time (x = ‘-40’ and y = ‘0’) ‘Relative’ to where Lazarus was standing. The

Page 5: Game Prototyping: Game Maker Tutorial 5: Lazarus Prototyping: Game Maker tutorial 5 – Page 1 Game Prototyping: Game Maker Tutorial 5: Lazarus ...  End the game Credits:

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 into obj_laz_stand (and ‘not’ perform Events).

4. Then create obj_laz_jump_right and assign it spr_laz_jump_right. It too needs

an Other: Animation End Event with the first Action being to Jump to a given position 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 to Change the instance back into obj_laz_stand (‘not’ Events).

5. It’s no surprise that you must also create obj_laz_jump_left and assign it

spr_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 after this 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 different this time. Now, when the animation has ended, the player is dead, so we’ll start with an Action to Display a message (that also 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. The second 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 Lazarus

Object (obj_laz_stand) and put in the rules for moving left and right that use 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 that out, as you’ll soon see…

7. Open up obj_laz_stand and let’s

start operating to build the Actions on the right. Create a Key Press <Right> Event and its first Action is to ask If there is a collision at a position with x = ‘0’ and y = ‘8’ against ‘Only solid’ Objects that are ‘Relative’ to Lazarus’ current position, as shown on the left. In other words, we’re checking to see if Lazarus is standing on something. That’s because we don’t want him jumping around while he’s in mid-air! So, we begin by asking the question of obj_laz_stand, “Are you standing on something?” If so, then do the next Action.

We’re asking if Lazarus is standing on

Saying “Yes”

The perform events option controls whether the Destroy Event of the current Object and the Create Event of the new Object should be performed (or “called” in the parlance of programmers).

This usually isn’t necessary, so Game Maker does not call them by default, but in this case we want to perform Events. Not for anything you can see now, but this will be important later when we add sound effects!

Page 6: Game Prototyping: Game Maker Tutorial 5: Lazarus Prototyping: Game Maker tutorial 5 – Page 1 Game Prototyping: Game Maker Tutorial 5: Lazarus ...  End the game Credits:

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 in

a Block so that they are performed together as a group. We need the Start of a block of code triangle, followed by the first Action, which is to ask If a position is collision free 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 the next Action, which is to Change the instance into ‘obj_laz_right’ and ‘yes’ perform Events (and check out the sidebar, “Saying ‘Yes’”). Next, place the Else Action from the control tab in here; I’ll explain that in more detail in a just a moment. Then once again ask If a position is collision free that is up and to the right of Lazarus (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 to Change 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 what should 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 with Else, you can specify a different Action (or group) to be performed if that same conditions is not true. This has many uses when making games. In this particular situation, the above Actions read this way: Is there solid ground beneath 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 jump on top of it. That’s just one possible outcome for this Event, of course. Technically, four different possibilities 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 to the 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 without Blocks following it. If Blocks are not used after the Else Action, then only the Action that immediately follows it is performed.

Page 7: Game Prototyping: Game Maker Tutorial 5: Lazarus Prototyping: Game Maker tutorial 5 – Page 1 Game Prototyping: Game Maker Tutorial 5: Lazarus ...  End the game Credits:

Game Prototyping: Game Maker tutorial 5 – Page 7

then read the next sentence. If the position to the right is collision free, then change into obj_laz_right; else, if the position diagonally right is collision free, then change into obj_laz_jump_right. Make sure you really comprehend the above logic; this is a key lesson from this tutorial. 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 a collision 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 solid ground. 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 a position is collision free to Lazarus’ immediate left (x = ‘-40’ and y = ‘0’ against Only solid Objects ‘Relative’ to Lazarus’ current position). If that’s true, then Lazarus should perform the next Action, which is to Change 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 of Lazarus (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 to Change the instance into ‘obj_laz_jump_left’ and ‘yes’ perform Events. Finally, set the End of a block of code to close up this group of Actions so that it looks like the mirror image of the preceding group for moving to the right.

STOP HERE and REVIEW Show Mrs MacLeod your notebook to be graded

Page 8: Game Prototyping: Game Maker Tutorial 5: Lazarus Prototyping: Game Maker tutorial 5 – Page 1 Game Prototyping: Game Maker Tutorial 5: Lazarus ...  End the game Credits:

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 is

currently no mechanism to bring him down when he’s in mid air. We’ll introduce “gravity” in class during Week 7 with The Platformer Game, but as you’ll discover with Game Maker, there is usually more than one way to accomplish anything. For now, we’re going to have Game 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 of movement down to determine how fast he falls, but our life will be easer if we set that speed to a number that divides exactly into 40 (i.e., the height in pixels of the boxes that he’ll be jumping from). Can you think why? Well, let’s imagine that you pick a number that doesn’t neatly divide into 40, like 12. During the first 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 fallen exactly 40 pixels which is exactly the 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 floating over above the boxes (4 pixels) of jammed inside of one (by 8 pixels). Using any number that divides 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.

Page 9: Game Prototyping: Game Maker Tutorial 5: Lazarus Prototyping: Game Maker tutorial 5 – Page 1 Game Prototyping: Game Maker Tutorial 5: Lazarus ...  End the game Credits:

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 is collision 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 see if 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 as shown on the left.

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

1. Create a new Sprite called spr_wall using wall.gif. Disable the Transparent option since the walls need to appear completely solid. Remember, when ‘Transparent’ is ‘on,’ every pixel in that Sprite that is the same color as the bottom-left pixel becomes ‘clear.’

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

3. Create a new Room called room_test and provide a Caption 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 both the Snap X and Snap Y to ’40’ as shown below. Because all of our boxes (including the wall ‘box’) are 40 x 40 pixels. Setting the grid to this size will help us to place them neatly into the Room when design the different levels. Note the change in the grid squares.

……………….

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 stars going left and right. Remember, you can hold down the <Shift> key to ‘paint’ an Object around the room making multiple copies. Add on instance of obj_laz_stand to the Room and you’re ready to test it out. Check the movement of Lazarus in all possible directions and situations to make sure that he’s behaving properly. If something isn’t working, retrace your steps and make sure that you have everything correct.

Page 10: Game Prototyping: Game Maker Tutorial 5: Lazarus Prototyping: Game Maker tutorial 5 – Page 1 Game Prototyping: Game Maker Tutorial 5: Lazarus ...  End the game Credits:

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 the means of escape. Once again, there are four types of falling boxes, from most to least heavy they are: stone, metal, wood and cardboard. The next type of falling box is chosen at random but is indicated 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 it first appears in the preview location; 2) when it falls down from the top of the screen and lands either on Lazarus or other boxes; and 3) when it finally forms a stationary obstacle for Lazarus to negotiate. As you may have surmised, that means we’ll be creating three different Objects for each 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 they have no transparent pixels. The create spr_box_metal and spr_box_wood using their respective graphic files. This time, leave the Transparent box enabled as these two Sprites have a small amount of transparency around their edges.

Your test level should look something like this.

Page 11: Game Prototyping: Game Maker Tutorial 5: Lazarus Prototyping: Game Maker tutorial 5 – Page 1 Game Prototyping: Game Maker Tutorial 5: Lazarus ...  End the game Credits:

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 as shown on the right. Then do the same for obj_box_metal, obj_box_wood, and obj_box_card making sure 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 screen right above Lazarus’ horizontal position – which means we’ll be using the ‘x’ variable for Lazarus 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, divides exactly into 40 (and you remember why that’s important, right?), and B) it is slightly slower than the speed at which Lazarus falls (and we don’t want Lazarus squished in mid air!). When a box collides with a heavier box, it turns into a stationary box (as we created above); when it collides with a lighter box, it destroys that 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 given position where x = ‘obj_laz_stand.x’ (that is, whatever Lazarus’ current ‘x’ position is) and y = ‘-40’ (which, as you know) is 40 pixels above the top of the screen) as shown here. The second Action for this Create Event is to Start moving in a direction: click the ‘down arrow’ and set the speed 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 this Collision 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.

Page 12: Game Prototyping: Game Maker Tutorial 5: Lazarus Prototyping: Game Maker tutorial 5 – Page 1 Game Prototyping: Game Maker Tutorial 5: Lazarus ...  End the game Credits:

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 Actions here: First, Start moving in a direction and have this object stop moving by selecting the Center Square and set the

Speed 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 with obj_box_stone. The two Actions are identical (i.e., it stops falling and becomes obj_box_stone). Three boxes to go.

Add a Collision Event with

obj_box_metal. Since metal is lighter than stone, 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 the instance of ‘Other’ in a Collision Event with obj_box_wood and obj_box_card as shown to the right.

WRITE THIS IN YOUR NOTEBOOK MATERIAL MATERIAL(S) THAT IT

CRUSHES Stone Metal, Wood, and Card Metal Wood and Card Wood Card

Page 13: Game Prototyping: Game Maker Tutorial 5: Lazarus Prototyping: Game Maker tutorial 5 – Page 1 Game Prototyping: Game Maker Tutorial 5: Lazarus ...  End the game Credits:

Game Prototyping: Game Maker tutorial 5 – Page 13

D. Creating the other falling box Objects. No doubt you can sniff out a pattern here and, with a little logic, can

create 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 they collide with the different types of 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, but the beginning. Programmers take 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-left corner to be previewed by the player. Allowing them to be previewed provides the player a strategic element in setting up Lazarus where he wants the next box to fall. With some quick thinking and reflects, the right row of boxes will be built-up or crushed through player skill in manipulating where the next box falls. These Objects are simple to make, but again, 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 it spr_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, and obj_next_card in the same way, making sure they have their corresponding Sprite and are Solid. That’s it for the boxes!

Card None

Page 14: Game Prototyping: Game Maker Tutorial 5: Lazarus Prototyping: Game Maker tutorial 5 – Page 1 Game Prototyping: Game Maker Tutorial 5: Lazarus ...  End the game Credits:

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 game that 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 know that 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 a Controller Object to do 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 box on 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!

Page 15: Game Prototyping: Game Maker Tutorial 5: Lazarus Prototyping: Game Maker tutorial 5 – Page 1 Game Prototyping: Game Maker Tutorial 5: Lazarus ...  End the game Credits:

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 a standing Lazarus Object as part of our queries for creating new boxes. This is because, in the Create Event for falling boxes, we used the variable ‘obj_laz_stand.x’ variable to place them in the correct position.

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

To avoid this, we simply check to make sure that there’s a standing Lazarus instance before creating any new falling boxes.

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 three obj_falling_[box type]s. So, only if there are no falling boxes around will we get down to the fifth question.

Create the fifth question, If the number of instances is a value for obj_laz_stand being ‘Equal to’ the number ‘1’ as shown above (see the 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, and there is an instance of Lazarus standing

around. Now what?

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

be done in answer to the last question, so we must put these Actions together in a Block of Code so that they are performed as 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, if obj_next_stone is in the view area, it’s going to change into obj_falling_stone which will make obj_next_stone disappear from the view area (it has been transformed and so is no longer a visible Object there) and start falling from the top of the screen (as you have instructed its new incarnation to do in the obj_falling_stone Create Event). Duplicate the above Action three times and make sure that each transforms its obj_next_[type]

Page 16: Game Prototyping: Game Maker Tutorial 5: Lazarus Prototyping: Game Maker tutorial 5 – Page 1 Game Prototyping: Game Maker Tutorial 5: Lazarus ...  End the game Credits:

Game Prototyping: Game Maker tutorial 5 – Page 16

into its obj_falling_[type]. By doing this, we’ve covered all of the possibilities for whatever type of obj_next_[type] box might be in the preview area. With all our bases covered, now we need to 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 to the 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 answer is “true”) means that the block of Actions at the end of it will only be performed if all of those Conditional Actions are true. In other words, if there are no instances of obj_falling_stone, and no instances 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 Maker drop 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 on them) 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 of obj_controller somewhere in the room. Don’t forget the Controller Object as it contains key rules and mechanics for play! Run the game and observe the gameplay carefully. Make sure that the box that appears in the 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 any problems, go back and fix them – you should be able to figure them out by now.

Page 17: Game Prototyping: Game Maker Tutorial 5: Lazarus Prototyping: Game Maker tutorial 5 – Page 1 Game Prototyping: Game Maker Tutorial 5: Lazarus ...  End the game Credits:

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 will start 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 shows Lazarus when he’s afraid. We’ll show that when the situation is nigh hopeless and he knows that the end is near. Rather than making a new Object for this state, we’ll just change the Sprite for the standing Lazarus when he’s “afraid” and change it back when he’s not. We can do this because “being afraid” doesn’t require any new or special Actions: that state has exactly 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 Lazarus depending on his situation. We’ll use the Collision Check Action to see if Lazarus is surrounded on both sides by boxes piled up two or more higher on both sides – if so, he’s afraid! Open up obj_laz_stand and select his Step Event. Add an Action asking If there is a collision at a position for the box on Lazarus’ right at x = ’40,’ y = ‘0’ against ‘Only solid’ objects that are ‘Relative’ to Lazarus’ current location. Duplicate this Action three times, and each time ask about another box location next to Lazarus. 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 entirely hopeless. After all, a heavy box on either side of Lazarus might crush things down and free our hero. When this happens, we need to tell Lazarus to stop looking afraid. Although we could include more Conditional Actions to check for this happening and change his Sprite back, there’s an easier way. We’ll just put in a Change the sprite Action at the top of the list of Actions for this Event that will set him back to his normal look. In other words, we’ll make spr_laz_stand the default Sprite every step and only change it when all of those Conditional Actions are true.

Page 18: Game Prototyping: Game Maker Tutorial 5: Lazarus Prototyping: Game Maker tutorial 5 – Page 1 Game Prototyping: Game Maker Tutorial 5: Lazarus ...  End the game Credits:

Game Prototyping: Game Maker tutorial 5 – Page 18

While still in the Step Event, add another Change the sprite Action only this time make the 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 like this don’t change the gameplay, they do enhance the experience and make it more entertaining.

B. The victory condition

We need to create a “Stop” button in the factory that halt the machinery so that the boxes stop dropping. All we’re really doing, however, is creating a devise that simply takes Lazarus to the next Room when Lazarus collides with it (much like the checkered flag we used in previous tutorial lessons). When there are no more Rooms, we’ll show a completion message and restart the game. Create a new Sprite called spr_button and use the corresponding art. Create a new Object called obj_button and set its Depth to ‘10’ so that it appears behind other Objects in the game as 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.

Page 19: Game Prototyping: Game Maker Tutorial 5: Lazarus Prototyping: Game Maker tutorial 5 – Page 1 Game Prototyping: Game Maker Tutorial 5: Lazarus ...  End the game Credits:

Game Prototyping: Game Maker tutorial 5 – Page 19

for a while Action, leaving it at the default 1000 milliseconds (i.e., one second) and leave redraw set to ‘true.’ This will buy the player a brief pause to realize that they’ve finished that level. Next, go to the main1 tab and ask If the next room exists. If that’s true, you want to perform 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 not being 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 and start 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 the moment, so choose it. After you have several Rooms (levels) created, you’ll want to come back 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 the previous 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. Go on; 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 no time to think or strategize. We’ll help the player out by adding a Starter Object that displays the 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 to Change the instance to obj_controller. You do ‘not’ need to perform Events.

Page 20: Game Prototyping: Game Maker Tutorial 5: Lazarus Prototyping: Game Maker tutorial 5 – Page 1 Game Prototyping: Game Maker Tutorial 5: Lazarus ...  End the game Credits:

Game Prototyping: Game Maker tutorial 5 – Page 20

Edit your test Room by removing the instance of obj_controller (with a right click) and replacing 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 the intervening levels. This is because the obj_title’s Create Event occurs before the window appears (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 asset creation and placement for these files. Create snd_music (this one loops as it’s the background music; the others don’t as they are sound 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: Game Start Event inside obj_controller as shown below.

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

Page 21: Game Prototyping: Game Maker Tutorial 5: Lazarus Prototyping: Game Maker tutorial 5 – Page 1 Game Prototyping: Game Maker Tutorial 5: Lazarus ...  End the game Credits:

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, adding snd_move as shown below for obj_laz_right.

Did you do all four of those? Okay, that leaves obj_button. Play snd_button at the very beginning of its Collision Event with obj_laz_stand as shown below:

Page 22: Game Prototyping: Game Maker Tutorial 5: Lazarus Prototyping: Game Maker tutorial 5 – Page 1 Game Prototyping: Game Maker Tutorial 5: Lazarus ...  End the game Credits:

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 moving around, check that you set the perform events to ‘yes’ for the Change instance Actions for the Key Press Events of obj_laz_stand (as shown below). If you didn’t, then Game 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 the left 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 or 10 total levels without working up a sweat. You should start with shallow pits and buttons on each side to keep things fairly easy 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 to falling boxes. And stationary boxes can even be placed in strategically detrimental locations. Boxes and buttons in mid-air can also add to the challenge.

Page 23: Game Prototyping: Game Maker Tutorial 5: Lazarus Prototyping: Game Maker tutorial 5 – Page 1 Game Prototyping: Game Maker Tutorial 5: Lazarus ...  End the game Credits:

Game Prototyping: Game Maker tutorial 5 – Page 23

One sure way to trip up players is to alter the speed of the game. In each Room, there is a settings tab that defaults to 30 Game Turns per second. You can decrease the number in the early levels to make those Rooms easier and ratchet it up on later Rooms to speed up the game and make those levels harder and harder. When building new Rooms, you should create a generic empty room with the basic foundations in it (walls, floor, and an instance of obj_starter) and Duplicate it to save yourself some time. After creating a few levels, you’ll want to find some playtesters to try them out and let you know how difficult they find them – games are usually much harder for players than 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 “cheat keys” to allow the playtester to move easily through the levels, gain extra lives, experience points, items, and so forth. For this game, a couple 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 Go to next room. Then add a Key Press <P> Event and for its only Action have it Go to previous room. In this way, can use the <N> key for ‘Next’ and <P> key for ‘Previous,’ you see?

H. Game Information Players will want some instructions when the press the <F1> key for Help. Open up the Game Information item at the bottom of the Asset List along the left side of the screen by double-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 a sample:

Page 24: Game Prototyping: Game Maker Tutorial 5: Lazarus Prototyping: Game Maker tutorial 5 – Page 1 Game Prototyping: Game Maker Tutorial 5: Lazarus ...  End the game Credits:

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 a sticky end. They have imprisoned him at the Blobfather'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 machinery. Do you have the reactions needed to help Lazarus build a way up, or will the evil mob claim 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 featuring

a 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 the other) 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 all the stationary boxes into stone boxes to ‘stabilize’ the environment (or cardboard boxes if you’re feeling evil).