NASA sends rovers to Mars to collect data and carry out scientific studies. The Perseverance Mars rover is designed to take that data collection one step further by gathering rock cores in sample tubes and leaving them on the surface for a future "fetch rover" to collect. The fetch rover would collect the samples and bring them to a Mars ascent vehicle – a rocket that would carry the samples from the surface to orbit around Mars – for eventual return to Earth.

In this project, you will use Scratch, a visual programming language, to create a video game that simulates the way NASA collects samples on Mars!

Screengrab of the Scratch interface with a window showing the background images for this activity

Materials

Screengrab showing background images being added to the Scratch interface

1. Get set up

Download the Jezero Crater surface images, the Mars sample collection tube image, and Mars fetch rover sprite image, and save them to a computer. Unzip the surface images zip file into a new folder.

  1. 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.)
  2. Create a new backdrop by moving the mouse over Choose a Backdrop in the Stage window and selecting Upload Backdrop. Pick the Jezero Crater surface image of your choice. The Stage area of the screen should now display your selected backdrop image. (See example image.)
  3. Create a new sprite by moving the mouse over Choose a sprite in the Sprite window and selecting Upload sprite. Choose the Mars fetch rover sprite image. There should now be a rover placed over your backdrop image along with the original cat sprite. (See example image.)
  4. Delete the existing cat sprite by clicking on it in the Sprites window and clicking the “x” in the corner.
  5. With the rover sprite selected, you’re ready to create the code that manages the game and controls the rover!

+ Expand image

Animated image showing a Mars image with a cartoon rover moving across the surface

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. For rovers to visit more than one place on 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. (See 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. (See 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.

+ Expand image

Animated image showing a Mars image with a cartoon rover moving across the surface collecting sample tube icons

3. Add sample tubes for collection

Sample tubes contain valuable rock samples collected by the Perseverance Mars rover and left behind for a fetch rover to collect. You should add sample collection tubes to your game to provide destinations for your rover. By studying the backdrop images closely, you can identify areas that look interesting and place sample tubes in those spots.

Tasks

  1. Add three or more sample tube sprites to visit during gameplay by placing the downloaded sample tube sprites to the backdrop by selecting Upload sprite the same way you did in Step 1.
  2. Make the sample tube sprites disappear when they are visited by the rover. Hint: See if a block in the Control section will help. (See example image.)
  3. Make the sample tube sprites reappear when players click the green flag to restart the game.

+ Expand image

Animated image showing a Mars image with a cartoon rover moving across the surface collecting sample tube icons as a timer in the upper left corner counts down

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

+ Expand image

Animated image showing a Mars image with a cartoon rover moving across the surface collecting sample tube icons as a timer in the upper left corner counts down as points are tallied in a score area

5. Add a scoring system

Rover missions on Mars don’t have a scoring system. 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 collecting sample tubes. How points are totaled is up to you. You could also program your game to reduce point totals in certain scenarios (see Step 6, for example).

Tasks

  1. Develop code to create a scoring system.
  2. Increase the score by one or more points for each sample tube collected.

+ Expand image

Animated image showing a Mars image with a cartoon rover moving across the surface avoiding neon green outlined areas

6. Add hazards

Space travel and other worlds are fraught with hazards. 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.

+ Expand image

An animated view looking down on the Perseverance rover as it's lowered on the surface of Mars with dust being churned up beneath it

7. Add landing code

Every Mars rover has to first land on the Red Planet before it can start exploring. 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.

About the image: This animated image is a clip from a video taken by the Perseverance rover mission as the rover was being lowered onto the surface of Mars. › Full video and caption

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.