| |
|
The idea of this tutorial is to give you a
quick introduction to Game Maker's founding principle: how the overall "game
loop" runs. Details on components such as sprites will be easier to
understand once this is.
Games always follow a game loop. In game maker, each time the created
game completes a loop, this is referred to as a "step" in the
documentation. When a step is done, the loop has been completely run,
and another step is about to begin.
You can set how long a step lasts in the room settings (the default
value is 30 steps per seconds, which means that if uninterrupted, the
step lasts 1/30th of a second).
During each step, one or several "events" may occur. An object may be
created and drawn, or a previously created object may be drawn again.
Game Maker being "event driven", this is extremely important to
understand.
You'll see in the interface that objects have associated events, which
in turn have associated actions. The first event that is necessarily
associated to an object is its creation. Once it is created, until it is
destroyed or disabled, the game will check it for further events at each
step.
Object properties
If it is visible, it will systematically be redrawn at each step. This
is the draw event.
The draw event's action by default is to draw the associated sprite at
the object's current coordinate. This means that unless you add a draw
event and associate it to your own list of actions, the game will just
draw the sprite you assigned to the object.
Let's take an example. The object is a monster, and at some point, if
the player does well, that monster is going to die some way or other. As
it dies, the sprite on the screen should change in some way. That means
that just drawing one same sprite no matter what isn't going to cut it.
That object will require that you associate actions to the draw event.
Actions in this case will be:
1)
Draw the normal sprite if it has not collided with a bullet.
2)
Draw the dying sprite if it has collided with a bullet, then destroy the
object.
If the same object has multiple instances (several copies of the same
monster pop in the room, like the ghosts in Pacman), then that object's
specific instance will be destroyed and not the others.
Other events can occur after the object is created. The player can press
a key (CTRL or SPACE), a pressed key can be released… Those are just the
examples in the screenshot.
The list of events that can be included to trigger actions appear when
you click on the Add event button.
The list of actions that can be associated to each of them is spread
accross the move, main1, main2, control, score, extra and draw tabs to
the right.
This is just an example that illustrates the founding principle of Game
Maker: Events and actions. Everything starts there.
|
|
|