Game Development Reference
In-Depth Information
Using a collision mask
Although our kart can move freely about the stage, it isn't in any way restricted to the road.
This doesn't make for much of a game. We need a way to check where the kart is driving,
and if it hits the sandbox or a wall, we should see some effect on the kart.
This means that we should start checking collision events. What do we check against?
The background image describes the shape of the racetrack, but it's a single object filling
the stage, so we can't check against the background by name. The kart drives on top of it,
so it always hits the background.
We could check for color, but the background is a detailed image. This means that we would
have to check for many different colors that would produce the same effect. It's hard to
determine if similar-looking colors are, in fact, equal. Computers are very precise about this.
So what we will do is create a simplified map to check the collision. We will draw all of the
important shapes, but leave out the details. Collision checks will be a lot less confusing this
way. This collision mask will be hidden from view, but the scripts will work with it. In this
way, it relates to the background in a way similar to how the control sprite relates to the
kart sprite.
Prepare for lift off
For this step, it will be really useful to have an external image editor. That would make
it much easier to work with complicated shapes, such as the curves in the road. You can
draw the collision mask in the Scratch editor too, but it will probably be less precise.
 
Search WWH ::




Custom Search