Session 4: Mini Capstone - Mars Rover Exploration Game
Theory & practice
🪐 Lesson 4: The Mars Rover Expedition Project
🚀 Mission to Mars
Congratulations on finishing the first stage of the course!
In this project, we combine everything we have learned to build a game where you control a robot exploring Mars.
You will use:
- Motion blocks.
- Loops.
- Variables.
if ... thenconditions.- Collision sensing.
- The keyboard to control a sprite.
🎯 Project objectives
After finishing, you will be able to:
- Control a sprite with the keyboard.
- Use loops to keep the game running.
- Use variables to store score and energy.
- Use conditions to detect objects.
- Build a game with a clear goal and rules.
1. Setting up the game
Sprites
Create or choose three sprites:
| Sprite | Role |
|---|---|
Mars_Rover | The robot the player controls |
Energy_Rock | The item to collect |
Crater | The obstacle to avoid |
Backdrop
Choose a backdrop showing the surface of Mars or outer space.
You can add:
- A research station.
- Marker flags.
- Rocks and volcanic craters.
- A mission message.
2. Creating the variables
Create three variables:
Score
Energy
TimeWhat each variable means:
Score: the number of rock samples collected.Energy: the robot's remaining energy.Time: the time left to finish the mission.
When the game starts:
when green flag clicked
set [Score] to [0]
set [Energy] to [100]
set [Time] to [60]
go to x: 0 y: 03. Driving the Mars Rover
The Mars Rover must check the keyboard continuously:
when green flag clicked
forever
if <key [up arrow] pressed?> then
change y by 5
change [Energy] by -1
if <key [down arrow] pressed?> then
change y by -5
change [Energy] by -1
if <key [right arrow] pressed?> then
change x by 5
change [Energy] by -1
if <key [left arrow] pressed?> then
change x by -5
change [Energy] by -1Every move uses up some energy, so the player needs to find a short, safe route.
4. Collecting energy rocks
Program the Energy_Rock sprite:
when green flag clicked
go to random position
show
forever
if <touching [Mars_Rover]?> then
change [Score] by 1
change [Energy] by 10
play sound [Collect]
go to random positionWhen the Mars Rover touches a rock:
- Score increases by
1. - Energy increases by
10. - The rock appears in a new place.
5. Avoiding craters
Program the Mars Rover to detect obstacles:
forever
if <touching [Crater]?> then
play sound [Alarm]
change [Energy] by -20
move -20 steps
say "Careful! Deep crater." for 2 secondsIf the rover drives into a danger zone, it loses energy and must back away.
6. Building a countdown timer
when green flag clicked
set [Time] to [60]
repeat 60
wait 1 seconds
change [Time] by -1After 60 seconds, the Time variable reaches 0.
7. Winning and losing
Mission complete
The player wins after collecting 5 rock samples:
if <Score ≥ 5> then
say "Mission complete!" for 3 seconds
stop allOut of energy
if <Energy ≤ 0> then
say "The Mars Rover is out of energy!" for 3 seconds
stop allOut of time
if <Time = 0> then
say "Time's up!" for 3 seconds
stop allPut these conditions inside a forever loop so the game keeps checking its state.
8. The complete rules
- 1The player has
60 secondsto finish the mission. - 2Use the arrow keys to drive the Mars Rover.
- 3Collect
5rock samples to win. - 4Every move uses up energy.
- 5Collecting rocks restores energy.
- 6Touching a crater costs a lot of energy.
- 7The game ends when you win, run out of time or run out of energy.
🧪 Project check
Before you finish, check that:
- The Mars Rover moves correctly in all four directions.
- Score starts at
0. - Energy starts at
100. - The countdown goes down once every second.
- The rock moves to a new place after being collected.
- Touching a crater reduces energy.
- The game stops correctly when you win or lose.
- Clicking the green flag restarts the game.
🧩 Extension challenges
You can upgrade the game by:
- Adding more craters.
- Speeding up after reaching 3 points.
- Adding special energy batteries.
- Creating several difficulty levels.
- Making the craters move.
- Adding an instructions screen before playing.
- Saving the high score in a new variable.
Example of increasing the difficulty:
if <Score = 3> then
say "Warning: a Martian storm is coming!" for 2 seconds
speed up the obstacles✅ Part 1 summary
In the Mars Rover Expedition project, you combined:
- Motion to control the robot.
- Loops to keep the game running.
- Variables to store score, energy and time.
- Conditions to handle collisions, winning and losing.
- Logical thinking to build complete game rules.
Quick questions
- 1Why should the win and lose conditions be inside a loop?
- 2When does the
Energyvariable change? - 3What happens when the Mars Rover touches a crater?
- 4Which feature would you add to make the game more fun?