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.
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 ...")
1. Get set up
Download the Mars surface images and the Mars helicopter 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!
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.
3. Add a takeoff location
The Mars helicopter will travel to the Red Planet on the belly of the Perseverance Mars rover. After Perseverance lands, it will place the Mars helicopter in its first takeoff location on the surface of the planet. You can specify a takeoff 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.
4. Add a landing site
The Mars helicopter will make up to five flights on Mars starting with a controlled vertical takeoff and landing. Later, its flights will become more complex, reaching heights of 10 to 15 feet and distances up to hundreds of meters.
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!
5. Add a countdown timer
NASA’s Mars helicopter will make incrementally longer flights, lasting up to 90 seconds. 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.
6. 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.
Comments