Micro:bit Game Project — Bug Catcher (Python)

1. Spec Sheet — Bug Catcher Game

Game Goal

Catch the bug as many times as you can before time runs out.

Game Rules / Behavior

Variables You Must Use

Grading / Expectations for Full Credit

  1. The game runs on a micro:bit using MicroPython.
  2. You can move the player with A, B, and A+B (down).
  3. The game correctly detects when you catch the bug and adds to your score.
  4. The bug relocates after each catch.
  5. The timer ends the game and the score displays.
BONUS / EXTENSION IDEAS

2. Pseudo Code (Game Logic Plan)

This is the logic in plain English. You should understand this before you code.

SETUP

  • Import micro:bit and random.
  • Set player_x = 2, player_y = 2 (start in middle).
  • Choose a random bug position:
    • bug_x = random 0..4
    • bug_y = random 0..4
    • If bug is on the player, pick again.
  • Set score = 0.
  • Set GAME_LENGTH = 20000 ms (20 seconds).
  • start_time = running_time() to mark the start.

MAIN LOOP (repeat while time not up)

  1. Check current time:
    • If time since start is greater than GAME_LENGTH, end the game.
  2. Read player input:
    • If A is pressed → move left (wrap at edge).
    • If B is pressed → move right (wrap at edge).
    • If A and B are both pressed → move down (wrap at bottom).
  3. Check collision:
    • If player_x == bug_x AND player_y == bug_y:
    • Increase score by 1.
    • Celebrate (sound / flash).
    • Move bug to a new random spot not equal to player.
  4. Draw the screen:
    • Clear display.
    • Draw bug as bright pixel.
    • Draw player as dimmer pixel.
  5. Sleep a short time so the loop doesn't run too fast.
END GAME:
- Clear the display.
- Scroll "SCORE:" and then the actual number.
- If score ≥ 5, show a happy face. Otherwise show a sad face.
- Stop.

3. Final MicroPython Code (Code to micro:bit)







The name of the file will be:
PX_lastname_Bug

Files to save on Google Drive under your class and submit to Google Classroom

  1. PX_lastname_Bug.png — Screenshot inside Python editor showing your code.
  2. PX_lastname_Bug.py — Your Python source file.
  3. PX_lastname_Bug.txt — Plain-text copy of your code.
  4. PX_lastname_Bug.hex — Hex file to run on the physical micro:bit.
  5. PX_lastname_Bug.mp4 — Short demo video of the program running on the board.

Submission requirements

Teacher / Student Reflection:
- Where in the code do we track time?
- Where in the code do we wrap around the edges?
- What part would you change to make the game harder?
- Can you add vertical movement (shake to move up)?