### Overview

In this activity, students create a Mars helicopter game using the Scratch programming language. They will engage in computational thinking, use math and include elements of real Mars helicopter planning to design their game.

### Management

• Note: If you’re unfamiliar with Scratch or block coding, review the Procedures section of the lesson Explore Mars with Scratch for help completing the tasks in this lesson.
• This activity is divided into multiple sections. One or more sections can be completed per class session.
• To save work, students will need individual accounts, or instructors can sign up for a teacher account to create and manage accounts for groups of students at http://scratch.mit.edu.
• Emphasize that the helicopter and game students create will only do what is coded. Also, remind students of the importance of sequence in coding. As students create code, allow them to explore what happens when they try different command blocks. There are many ways to achieve certain results and not every student or group will create the same code or game.
• Students should run and debug their code throughout the programming process rather than waiting to test everything at the end.

### Background

NASA’s Mars helicopter, named Ingenuity, is a technology demonstration intended to prove that a small, lightweight helicopter can fly in the thin atmosphere of Mars.

The helicopter completed its technology demonstration after three successful flights. For the first flight on April 19, 2021, Ingenuity took off, climbed to about 10 feet (3 meters) above the ground, hovered in the air briefly, completed a turn, and then landed. It was a major milestone: the  first powered, controlled flight in the extremely thin atmosphere of Mars. After that, the helicopter successfully performed additional experimental flights of incrementally farther distances and greater altitudes.

NASA’s Perseverance Mars rover took a selfie with the Ingenuity helicopter, seen here about 13 feet (3.9 meters) from the rover in this image taken April 6, 2021, the 46th Martian day, or sol, of the mission by the WATSON camera located at the end of the rover's long robotic arm. Image credit: NASA/JPL-Caltech/MSSS | + Expand image

With its tech demo complete, Ingenuity transitioned to a new operations demonstration phase to explore how future rovers and aerial explorers can work together.

NASA and the European Space Agency (ESA) are planning ways to bring the first samples of Mars material back to Earth for detailed study. The Mars Perseverance rover is the first leg of this international interplanetary relay team. Its job is to collect and cache samples on Mars. A Sample Return Lander would land near or in Mars' Jezero Crater, bringing a small rocket on which the samples collected by Perseverance would be loaded. Two Ingenuity-like helicopters arriving with the lander will provide a secondary capability to retrieve samples on the surface of Mars if the rover was unable to transfer them to the lander.

Depicted in the foreground of this illustration is one of two Sample Recovery Helicopters slated to fly to Mars as part of the Mars Sample Return Campaign. In the upper right is the Ingenuity Mars Helicopter, currently operating at Jezero Crater. In the upper center of image is the Mars Science Helicopter concept that could be used during future Mars missions. Image credit: NASA/JPL-Caltech | + Expand image

Mars helicopters can’t be 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 fly helicopters. And for the purposes of this lesson, students will program their game to use keys on a keyboard to make the helicopter fly.

### Procedures

This lesson is broken down into seven sections that guide students through how the Mars helicopter works and what to consider when creating their game. You can choose to have students complete any number and combination of the sections below (Section 1 is required for all other sections). If appropriate, have students view the student project version of this lesson and work independently to complete the tasks.

(10-20 minutes)

(10-20 minutes)

(10-20 minutes)

(10-20 minutes)

(10-20 minutes)

(10-20 minutes)

(10-20 minutes)

#### Section 1 - Create a Flyable Helicopter(10-20 minutes)

1. Students should download the Mars surface images, the Mars helicopter sprite image, and the Mars sample collection tube sprite, and then unzip the surface images into a new folder.
2. On the Scratch website, students will Create a new project using a surface image, helicopter sprite, and Mars sample tube collection sprite.
3. Students should delete the existing cat sprite by clicking on it in the Sprites window and clicking the “X” in the corner.

4. With the helicopter sprite selected, students will create the code that controls the helicopter.

Students should consider:

• Which keys will control the helicopter and which keys (if any) should perform other functions they might add to their code later.
• How they can make the motion of the helicopter smooth and realistic.

Now is a great opportunity to remind students that there are multiple ways to create code that will accomplish the same thing.

#### Section 2 - Add a Take-Off Location(10-20 minutes)

The Mars helicopter traveled to the Red Planet on the belly of the Perseverance Mars rover. After Perseverance landed, it placed the Mars helicopter in its first takeoff location on the surface of the planet. Students can specify a takeoff location for their helicopter by creating scripts that place it at a certain location at the beginning of the game.

Students should consider:

• Realistic starting points (e.g., land vs. sky).
• How to make the helicopter start in a different location each time the game starts.
• How to avoid selecting a starting point for the helicopter on the landing site or the Mars sample tube site created in Section 3.

#### Section 3 - Add a Landing Site(10-20 minutes)

Students should create a landing target for the helicopter. They can draw a landing location with the backdrop editor, or add a sprite that will serve as a landing target.

Students should consider:

• Where the landing location will be placed.
• How a sprite will respond when the helicopter reaches it (e.g., spin, disappear, etc.).

Remember: Click on the helicopter sprite to add code for the helicopter. Otherwise, additional code might be added to the backdrop or the landing site sprite, rather than the helicopter sprite.

Student Bonus Challenge: Generate code that identifies an unmarked region as a safe landing area that game players must find by attempting to land in different regions. Remember, students will want to place these unmarked regions in areas without large rocks!

#### Section 4 - Add Mars Sample Collection Tubes(10-20 minutes)

The Perseverance Mars rover is collecting samples and depositing them on the surface of the Red Planet for retrieval by a future mission. These sample tubes could be collected by helicopters similar to Ingenuity and delivered to a lander and launch vehicle for return to Earth if Perseverance was unable to deliver onboard samples to the lander. Students can add multiple Mars sample collection tube sprites that will serve as gameplay elements.

Students should consider:

• Placement of the sprites.
• How the sprites will interact with the helicopter when it reaches them.
• Where to deposit the sample tubes after collection.

#### Section 5 - Add a Countdown Timer(10-20 minutes)

One constraint that limits the flight time of the Mars helicopter is the amount of power stored in the helicopter's batteries. Students can create a timer that counts down to the end of the flight and ends the game.

Students should consider:

• What amount of time makes the game challenging yet winnable.
• If the timer should be visible to players or hidden from view.
• What will occur when the timer reaches zero.

#### Section 6 - Add a Scoring System(10-20 minutes)

Missions on Mars don’t have a scoring system, but the science collected is valuable, and some discoveries may be more exciting, interesting, or important than others. To determine how well players are doing, students can develop a scoring system that tallies points as Mars sample tube sprites are collected.

Students should consider:

• How points are tallied.
• If some tubes are worth more than others.
• Scenarios that might lead to reduced point totals.
• How points are displayed.

#### Section 7 - Transmit Mission Success to Earth(10-20 minutes)

To mark the successful completion of the game (e.g., that the helicopter collected some or all of the Mars sample collection tubes), students should generate code that displays a mission success message, stops game play, and prevents any mission failure messages from displaying.

Students should consider:

• How many Mars sample collection tubes must be collected to win.
• If players must fly to the landing site created in Step 4 to win.
• What message will be displayed.
• How the game will be reset to play again.

### Discussion

• Ask students if they think flying with a joystick (or with cursor keys, like in this game) is possible and to explain their reasoning. Ask students how far they think Mars is from Earth. The distance to Mars – between 78 million and 378 million kilometers (48 million to 235 million miles) – causes a delay of several minutes when mission operators send commands between Earth and Mars, making remote control with joysticks or keyboards impossible. Instead, operators send a series of commands to be completed by the spacecraft.

### Assessment

Students should take turns testing out other students’ games to see if they are working as planned. Student players should provide feedback about what happened when they played as well as what they thought should have happened.

• Does the game do what it’s supposed to as described by the game creator?
• Is the game winnable (i.e., can players complete the tasks, or was the game designed to frustrate players or be unbeatable)?
• Have ways that players can “cheat” the game been eliminated through code?
• Did the game creators go beyond the basics and explore the addition of creative or more in-depth scripts?
• Did students refine or combine their scripts to make them more efficient or organized?
• Refer to the coding rubric.

### Extensions

Student Bonus Challenges:

• Create a script that uses sprite costumes to make the helicopter appear to rotate.
• Develop code to bring the helicopter down to the ground regardless of where it is when the timer reaches zero.
• Student coders can create a backdrop with a takeoff and landing location, but not include scripts to control the helicopter. In this case, players of the game would have to create a series of scripts that would fly the helicopter where they want it to go in order to reach the landing location. The script would run a single time when the Green Flag is clicked and wouldn’t include arrow keys to control the helicopter.