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

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 ‘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.

  1. 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 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 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.

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 tothe 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, 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

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.


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.