Professional Documents
Culture Documents
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, youll get some much-needed practice
using a Controller Object for storing Game Rules outside of the games playing pieces.
In Lazarus, the player is a cute little blob who has been abducted by the Blob Mob and sent to the
Blobfathers 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
well 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.
A. Well 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). Youll soon see why thats 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
Smooth Edges
when you first load the graphic, the smoothing check box is right
This function is
hand side. This Sprite, youll notice, is 80 x 80 pixels and its
particularly good for
Sprites that animate or
animation shows Lazarus jumping 40 pixels to the right (you can press the blue arrow
otherwise move around.
button to preview the animation one frame at a time).
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.
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 its 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 Points 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
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. Its 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 were 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 well start with an Action to Display a message (that
also pauses the game until the player clicks on the OK button)
something like, YOURE 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.
Thats all of the animations, now we need to get back to the main Lazarus
Have you saved
Object (obj_laz_stand) and put in the rules for moving left and right that
your game lately?
use these Animation Objects. To figure out if Lazarus is stuck, must jump,
or simply moves in a direction, well use the Conditional Collision Action to work that
out, as youll soon see
7. Open up obj_laz_stand and lets
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.
Were 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 isnt 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!
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 thats 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; Ill 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 thats 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
What Else?
u
pLike 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
tperformed.
h
is 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.
Thats 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.
Heres 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 lets 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 thats 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 thats 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 thats 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.
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 hes in mid air. Well introduce gravity in class
during Week 7 with The Platformer Game, but as youll discover with Game Maker, there is usually
more than one way to accomplish anything. For now, were going to have Game Maker check every
Step (i.e., well 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 hell be jumping
from). Can you think why?
Well, lets imagine that you pick a number that doesnt 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 hell 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. Well 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 youve been doing, with x = 0 and y = 8 against
Only solid objects that are Relative to this Object. In other words, lets check to see
if there is nothing under Lazarus feet, and if thats 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. Youve done a lot of steps without being able to check them, so lets 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, well 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 hes
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 youre ready to test it out.
Check the movement of Lazarus in all possible directions and situations to make sure
that hes behaving properly. If something isnt working, retrace your steps and make
sure that you have everything correct.
than
times.
with
Stone
Metal
Wood
D.
Card
None
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. Theyre 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!
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 arent 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 youre designing the level (i.e., Room) but that players wont 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. Were 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 isnt, 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.
Add a Step: Step Event and brace yourself. Youre 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.
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 cant provide that Objects 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 theres a
standing Lazarus instance before creating any new falling
boxes.
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, its 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]
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 dont 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 were 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, well 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
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 theyve finished
that level.
Next, go to the main1 tab and ask If the next room exists. If thats 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, well 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, youll 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; youre done.
This is out by adding an instance of obj_button to the top of either side of the Room. Go
on; Ill 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. Well 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.
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.
Youll notice that the title image doesnt appear before the first level starts; only during the
intervening levels. This is because the obj_titles 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 its the background music; the others dont 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
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:
Test the game and check out your new audio. If you dont 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 didnt, then Game Maker
wnt 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 midair can also add to the challenge.
30
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