Animated image of the Mars rover sprite collecting yellow stars representing science targets.

Create a Moon or Mars exploration game using Scratch, a visual programming language. Think like NASA space-mission planners to design your game!

› Educators, explore how to turn this into a lesson for students

Scratch project dashboard and a window showing options for Mars surface images.

Materials

Screengrab of the Mars rover sprite on top of a Mars surface image

1. Get set up

  1. Download the Moon or Mars surface images and the Moon or Mars rover sprite image, and save them to a computer. Unzip the surface images zip file into a new folder.
  2. On the Scratch website, click Create to begin a new project. (Sign in or create an account, if you want to save your work so you can revisit or redesign your game in the future.)
  3. Create a new backdrop by moving the mouse over Choose a Backdrop in the Stage window and selecting Upload Backdrop. Choose the Moon or Mars surface image of your choice. The Stage area of the screen should now display your selected backdrop image. Click for example (image)
  4. Create a new sprite by moving the mouse over Choose a sprite in the Sprite window and selecting Upload sprite. Choose the rover sprite image. There should now be a rover placed over your backdrop image along with the original cat sprite. Click for example (image).
  5. Delete the existing cat sprite by clicking on it in the Sprites window and clicking the “x” in the corner.
  6. With the rover sprite selected, you’re ready to create the code that manages the game and controls the rover!
Animated image of the Mars rover sprite moving right, up, left and down.

2. Make the rover drive

NASA explores Mars with orbiters that travel around the planet, stationary landers on the ground and rovers that can travel many miles on the surface. Astronauts have also explored the Moon with a car-like rover – and might again in the future. For rovers to explore the Moon or Mars, they must be able to drive. Rovers on Mars aren’t controlled with joysticks or keyboards. But in the future, astronauts in orbit around Mars or on the surface of the planet could use remote controls to drive rovers. Your game can use keys on the keyboard to make the rover drive.

Tasks

  1. Make the rover move up, down, left and right on the screen using four different keys on the keyboard. Hint: See if a block in the Events section will help. Click for example (image)
  2. Specify how far the rover will move each time one of those keys is pressed. Select a distance that makes the rover movement appear smooth when the key is pressed and held. Hint: See if a block in the Motion section will help. Click for example (image)
  3. Make the rover rotate so it points in the direction of travel.
  4. Bonus: Make the rover move diagonally using keys other than the keys already assigned.
Animated image of the Mars rover sprite collecting two science targets, represented as yellow stars. The stars disappear when the rover touches them.

3. Add science targets

NASA sends rovers to Mars to collect data and carry out scientific studies. Astronauts on the Moon will drive rovers to areas of scientific interest. “Science targets” are the locations and objects on which these studies are carried out. You should create science targets to provide destinations for your rover. By studying the backdrop images closely, you can identify areas that look interesting and that you think scientists might want to study.

Tasks

  1. Add three or more science targets to visit during gameplay by placing additional sprites representing the targets on the backdrop image.
  2. Make the science target sprites disappear when they are visited by the rover. Hint: See if a block in the Control section will help. Click for example (image).
  3. Make the science target sprites reappear when players click the green flag to restart the game.
Animated image of the Mars rover sprite rolling collecting science targets (yellow stars) while a timer counts down to 0. The timer runs out and a word bubble says "Mission Over."

4. Add a countdown timer

NASA’s missions to Mars and other destinations have a planned life expectancy. Some missions, including every Mars rover to date, have been extended and operated beyond their planned mission life expectancy, while others experience problems that shorten their mission. You can create a timer that counts down to the end of the mission and ends the game. Your timer should not be so short that the game is unplayable or unwinnable, but it should not be so long that there is no challenge to playing the game. As a bonus, you can create code to extend or shorten the planned mission time.

Tasks

  1. Create a timer that counts from a set time down to zero. Hint: Create a Time variable that you can program to change. Click for example (image)
  2. Make gameplay stop when the timer reaches zero.
  3. Make a “Mission Over” message appear when the timer reaches zero.
  4. Make the timer start over when a player clicks the green flag to restart the game.
  5. Bonus: Develop code that will increase or decrease the amount of time on the timer by one or two seconds at random.
Animated image of the Mars rover sprite collecting science targets while a timer counts down to 0 and a score counter goes up by one point as the targets are collected.

5. Add a scoring system

Rover missions on Mars don’t have a scoring system, and astronauts aren’t given points for science discoveries on the Moon. But the science they collect is valuable, and some discoveries may be more exciting, interesting or important than others. To determine how well players are doing while playing your game, you can develop a scoring system that includes points earned for reaching science targets. How points are totaled is up to you. You could also program your game to reduce point totals in certain scenarios.

Tasks

  1. Develop code to create a scoring system.
  2. Increase the score by one or more points for each science target visited.
Animated image of the Mars rover sprite driving around an L-shaped "hazard" and then running into it. When the rover runs into the hazard, a word bubble reads "Hazard!"

6. Add hazards

Space travel is fraught with hazards, both in space itself and on planets and moons. From steep slopes and deep sand to sharp rocks and high radiation, there are countless ways a mission can be delayed or end unexpectedly. Program your game to include hazards that players need to avoid. Look for dark areas in your backdrop image. These shadowed regions are often steep slopes that a rover could get stuck on.

Tasks

  1. Develop code that identifies hazardous locations on the backdrop image.
  2. Add in undesirable outcomes that occur when the rover reaches hazardous locations. (For example, the game could stop, time might be taken away, points might go down, etc.)
  3. Make a “Hazard” message appear when players encounter a hazard.
  4. Make some hazards hidden and some visible.
  5. Bonus: Make a hidden hazard that changes location each time the game is restarted.
Animation of the Mars rover Curiosity landing on the Red Planet.

7. Add landing code!

Every Mars rover had to first land on the Red Planet before it could start exploring, as will rovers on the Moon in the future. You can specify a landing site by creating scripts that place the rover at a certain location at the beginning of the game.

Tasks

  1. Create code that puts the rover in a specific location at the beginning of the game.
  2. Bonus: Modify your landing code to make the rover land in a random location on the backdrop image, or in a random location within a smaller section of the backdrop image.

8. Take it farther!

Now that you’ve created your game, let others play it and suggest improvements! Also, check out this Mars rover game from NASA for more inspiration.