Game Development Reference
In-Depth Information
6. Repeat this process, loading all the images until you have 16 sprites called:
spr_gold , spr_lava_begin , spr_lava_end , spr_lava_middle , spr_pansy ,
spr_pod_fall_left , spr_pod_fall_right , spr_pod_jump_left , spr_pod_jump_right ,
spr_pod_stand_left , spr_pod_stand_right , spr_pod_walk_left , spr_pod_walk_right ,
spr_rock_begin , spr_rock_end , and spr_rock_middle .
This kind of thing should be second-nature to Game Maker users, so from now on, we will
assume you can load and name resources appropriately without quite as much help. We will also
assume that you will base your resource names on the original file names (removing the file
extension from the end and _stripXX where necessary)—if you don't, then you may get confused
when we refer to the names in this way later on in the instructions!
Tip Don't forget to save your work regularly by clicking on the blue disk icon on the main toolbar.
Collision Masks
Before we can move on, there is something very important that we need to do to the sprites that
may seem a bit counter-intuitive. One of the cool things about Game Maker's sprites is that they
have a Precise Collision Checking option, which performs pixel-perfect collision detection
between different instances in your games. Every new sprite you create has this option enabled
by default, and it means that you'll only get collision events when there is a visible overlap
between the sprites of two different instances in the game (see Figure 2-2). After all, why would
you want anything else?
Figure 2-2. The situation on the left wouldn't trigger a collision event with precise collision, as there are no
overlapping pixels between the character and platform sprites. The situation on the right has overlapping
pixels and so would trigger a collision
Well, let's look at an example. In the Chapter02/Games directory, you will find two executables
that show alternative approaches to collision detection in the game we're about to make. Begin
by running precise_collision.exe and use the arrow keys and space bar to move and jump the
green character around the level. This version illustrates precise collision detection in action
where the shapes represent the exact collision masks that are used by Game Maker to determine
collisions. These collision masks are simply the visible pixels of your sprites, allowing for perfect
 
Search WWH ::




Custom Search