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...