Student Project .
.Code a Mars Helicopter Video Game
Create a video game that lets players explore the Red Planet with a helicopter like the one going to Mars with NASA's Perseverance rover! Use Scratch, a visual programming language and think like NASA space-mission planners to design your game!
Watch the Tutorial
See below for materials and step-by-step instructions. For more video tutorials and activities like this one, visit Learning Space.
Watch en Español: Seleccione subtítulos en Español bajo el ícono de configuración.
In this episode of Learning Space, you'll create a video game that lets players explore the Red Planet with a helicopter like the one going to Mars with NASA's Perseverance rover! | Watch on YouTube
Materials
- Computer with internet access
- Free Scratch account
- Mars surface images – Download ZIP
- Mars helicopter sprite image – Download PNG (right-click and select "Save Link As ...")
- Mars sample collection tube sprite image – Download PNG (right-click and select “Save link as…”)
Project Steps
Step 1: Get set up
Step 1: Get set up
- Download the Mars surface images, the Mars helicopter sprite image, the Mars helicopter sprite image, and the Mars sample tube sprite image, and save them to a computer. Unzip the surface images zip file into a new folder. There are jpg and png versions of each file.
- 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.)
- Create a new backdrop by moving the mouse over the Choose a Backdrop icon in the Stage window and selecting Upload Backdrop. Pick the Mars surface image of your choice. The Stage area of the screen should now display your selected backdrop image. Click for an example (image).
- Create a new sprite by moving the mouse over Choose a sprite in the Sprite window and selecting Upload Sprite. Choose the helicopter sprite image. There should now be a helicopter placed over your backdrop image along with the original cat sprite. Click for example (image).
- Delete the existing cat sprite by clicking on it in the Sprites window and clicking the “x” in the corner.
- With the helicopter sprite selected, you’re ready to create the code that manages the game and controls the helicopter!
Step 2: Make the Helicopter Fly
Step 2: Make the Helicopter Fly
NASA’s Mars helicopter is a technology demonstration intended to prove that a small, lightweight helicopter can fly in the thin atmosphere of Mars. The helicopter on Mars won’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. Your game can use keys on a keyboard to make the helicopter fly.
Tasks
- Make the helicopter fly up, down, left and right on the screen using four different keys on the keyboard. Hint: See if a block in the Control section will help. Click for example (image).
- Specify how far the helicopter will move each time one of the keys defined above is pressed. Select a number that makes the helicopter 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).
- Make the helicopter stay oriented with its rotor on top no matter what direction it is traveling.
- Bonus: Create a script that uses sprite costumes to make the helicopter appear to rotate.
Step 3: Add a takeoff location
Step 3: Add a takeoff location
After the Perseverance Mars rover landed on the Red Planet, it placed the Mars helicopter in its first takeoff location on the surface of the planet. You can specify a take-off location for your helicopter by creating scripts that place it at a certain location at the beginning of the game.
Tasks
- Create code that puts the helicopter in a specific location at the beginning of the game. Make sure it's starting on the ground, not in the sky!
- Bonus: Modify your landing code to make the helicopter start in a random location on the ground.
Step 4: Add a landing site
Step 4: Add a landing site
Just like helicopters on Earth, the Mars helicopter will need to land.
Tasks
- Create a visible landing target on the backdrop image. You can draw a landing location with the backdrop editor, or add a sprite that will serve as a landing target. Avoid putting the landing target over large rocks that could damage the helicopter upon landing. While the real Mars helicopter won’t have a marked landing spot for its flights, your game players will need to know where to land.
- Bonus: 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, you'll want to place these unmarked regions in areas without large rocks!
Step 5: Add Mars Sample Collection Tubes
Step 5: Add Mars Sample Collection Tubes
The Perseverance Mars rover is depositing sample tubes filled with rock samples on the surface of the Red Planet that could be collected by Ingenuity-like helicopters for return to Earth on a small rocket. You can give players a task by adding Mars sample collection tubes that need to be collected.
Tasks:
- Add two or more sample tube collection sprites to the game.
- Develop code that will cause the tubes to indicate they have been collected when the helicopter reaches them.
Step 6: Add a countdown timer
Step 6: Add a countdown timer
One constraint that limits the flight time is the amount of power stored in the helicopter's batteries. You can create a timer that counts down to the end of the flight 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 successfully playing the game. You may need to adjust your timer if you change your helicopter’s speed or the landing site.
Tasks
- 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).
- Make gameplay stop when the timer reaches zero.
- Make a “Mission Over” message appear when the timer reaches zero.
- Make the timer start over when a player clicks the green flag to restart the game.
- Bonus: Develop code to bring the helicopter down to the ground regardless of where it is when the timer reaches zero.
Step 7: Add a scoring system
Step 7: Add a scoring system
Missions on Mars don’t have a point 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 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.
Tasks:
- Develop code to create a scoring system.
- Increase the score by one or more points for each sample tube collected.
Step 8: Indicate mission success!
Step 8: Indicate mission success!
The Mars helicopter is a technology demonstration mission. It will help NASA prove that a helicopter can fly on Mars, something that has never been done. Mission success for the Mars helicopter will be achieved when it makes its first controlled flight on Mars.
Tasks
- Create code that announces a successful mission once the helicopter safely lands on the landing site.
- Make gameplay stop when the landing occurs.
- Make a script that stops the mission-over script from running when mission success has been achieved.
Lesson Last Updated: Oct. 11, 2024