"Return to Mars!"

Programming a Simple Maze Game in Scratch

This Scratch project demonstrates how to create a maze background for the stage, color-code the sprites to "bounce" off the walls and stay within the maze, and use the four arrow keys to guide your Martian UFO back to Mars.

Create two blank backgrounds and use the text tool to create a title sequence and directions for how to play the game.

Start with a blank background, choose a solid color and draw a simple maze. Don't make it too complicated, or your sprites will have to be really small and hard to see, if they are to move around in the maze.

The slightly different colored gray lines at the bottom right corner and in the second bottom left corner are different shades to help the red rocket and the asteroides "to bounce" at each end of their paths.

Most of the scripting goes into the "viewpoint sprite," or the flying saucer.

The first "obstacle sprite" in the way of our viewpoint sprite, the flying saucer, is the planet Saturn. I had it "appear" and "disappear" for several second intervals, so that the player has to time his flying to pass through Saturn's space while it is invisible.

The red rocket and the asteroids sprites both operate under a similar pattern. They move back and forth, each one "bouncing" off one end of a gray wall the way the Martian flying saucer does, but using a slightly different color to flip the sprite and have it move back in the opposite direction.

After the flying saucer evades Saturn, the red rocket and the asteroids, it "lands" on its home planet, Mars, with an appropriate celebration.

Here the the final game, ready for blast off!

Return to Scratch Main Page