
GAMEMAKER
CONTENT

SPRITES
A sprite is
an image that is used inside a game. Often, a sequence of sprites
is displayed one after another to create the illusion of animation.
Sprites
are used for characters, bad guys, objects, walls and even backgrounds
(sometimes).
Here
is an image of 82 different sprites used in a Super Mario Brothers game:

COMPUTER
EVENTS
In
computers, an event is a special type of activity that
computer programs watch or listen for. Here are some examples of
events that an application might be watching for:
- a mouse button
is clicked anywhere;
- a mouse is
clicked while the cursor is on an object;
- a keyboard key
is pressed;
- two objects
collide;
- the mouse cursor
is moved over an object;
- a timer runs out.
Another
type of event is a creation event that runs whenever an
object instance is first created.
ACTIONS
An action is what happens as a response
to an event. This is best explained via examples:
If
a character gets hit by a rocket and should disappear, then we have:
- Event: A
collision event between a character and a weapon.
- Action:
Character is removed from scene
If
the mouse is clicked on a button that makes a window pop up, then we have:
- Event: A mouse
click event
- Action: A new
window is opened with specified data
OBJECTS
(IN GAME MAKER)
In
Game Maker, an object is a prototype. You create
a prototype object and then you can use as many instances (copies) of that object in your game.
Note
that unfortunately the term object is used in opposite ways in many
programming languages.
ROOMS
In GameMaker, rooms are simply
the location inside which all objects interact. Usually, we use a
different room for each level that we do. Rooms are also used for
intro screens and ending screens.

STEPS
GameMaker, just like all computer games,
separates time into finite sections called steps. Every second, there
are 30 steps that occur. (This amount
can be changed in the settings tab
of a room. However, the higher the
steps per second, the more difficulty your CPU will have to keep up with the
game.)
ALARMS
Alarms, also known as alarm clocks, are
special devices that are set to a number of steps such as 60. Then they automatically count down to
zero. Once zero is reached, an alarm
event occurs and the corresponding actions are done.
By default, GameMaker runs at 30 steps per second. So we set an
to 60, it
will take 2 seconds for it to trigger an alarm event.
ALARM EVENTS &
ACTIONS
Any object
can make use of 10 different alarms (from zero to nine).
We place the
alarm event code inside the object and add any corresponding actions.
We also need
to start the alarm (SET ALARM action).
This is often done in the create event.
CONTINUOUS REPETITION
We often want
to repeat an action every so often. We
do this by resetting the alarm inside the alarm event.
EXAMPLE
If we wanted
to continuously play a sound every 100 steps, we would do something like
this:
- In the creation event of your main character, you
set an alarm to a certain number of steps. The alarm will automatically count
down to zero.
- Still in the main character, you add an event for
that alarm. Inside, you add the
action to play the sound. You
also reset the alarm to the number of steps that want before the sound
plays again.

COORDINATES
Remember your
graph work in math with the x and y axis’s?
Well, you need to know a little about this for Game Maker. Each pixel in the room window is given a
coordinate. At the very top left, you
find (0,0). Just to the right of that,
you find (0,1).
To help find
the maximum size of the room, there are built in variables to specify that
size. The words room_height and room_width
specify the height and width of the room in pixels.
So
the point (0,room_height) is at the bottom left.
The
point (room_width, room_height)
is at the bottom right.
The
point (room_width, 0) is at the top right.
VARIABLES
What are they?
Variables are
what allow us to store data in the computer.
For example, the location of your character is stored in an x variable
and a y variable. Your score is also
stored in a variable. The number of
the current level is also stored in a variable. All data is stored in some sort of
variable.
Common variables
x – inside an
object, this refers to the object’s x coordinate inside the room
y – inside an
object, this refers to the object’s y coordinate inside the room
room_width – the room’s width in pixels
room_height – the room’s height is pixels
RANDOM VALUES
In computer
applications, it is often necessary to generate random values. In GameMaker, we
have a built-in function (or command) called random that we can use.
To get a
random number between 0 and 500, we use:
random(500)
To get a
random number between 0 and 10, we use:
random (10)
To get a
random number between 0 and the room’s width, we use:
random(room_width)
IF STATEMENTS
What are they?
If statements
are added in the actions section of an event to check if certain conditions
are true. Based on the result of this
check, some actions may be executed or skipped.
If statements
are how computers make decisions.
Example
Here are a
few examples:
If character’s health is less than
0, then display GAME OVER
If the plane is as far left as it
can go, then do not let it move further left

Multiple Rooms
Having
multiple rooms is very easy. Simply
make more than one room. At whichever
point you want to go to the next room, you simply apply the Next Room action.
If you apply
this action where there is no next room, the game will crash. However, there is a way to check if there
is another room.
Start Screen
You can use
the first room to place a neat start screen graphic. Adding an event that listens for any key to
be pressed and moving to the next room allows you to easily start the game.
Object Creation
Every time
you start a new room (or restart a room), the object’s CREATE event is
executed.
Therefore,
setting things like score and lives should be done in an object that
does not appear on any of the levels.
The best
solution is to have a Start screen that has an invisible object that sets
this information for you.

|