Designed and built a microcontroller-based Space Invaders game using Java, Python, and MicroBlocks on the BBC micro:bit with an 8×8 NeoPixel LED display. Developed test-driven logic with JUnit and unittest, and showcased the project to John Maloney, co-creator of Scratch and MicroBlocks.
- Player-controlled movement using micro:bit buttons (A = left, B = right, A+B = shoot).
- Enemy AI that moves downward and side-to-side with timing and pattern control.
- Collision detection for bullet-enemy interactions.
- Score tracking to keep track of player's progression in the game.
- NeoPixel LED animations to show player (
blue), enemy (green), and bullet (red). - Game Over logic triggers when the enemy reaches the player's position.
Python (console simulation), Java (logic simulation), MicroBlocks, BBC micro:bit, NeoPixel (8x8 LED grid)
| Variable | Description |
|---|---|
player |
X-position of the player on the bottom row (7) |
enemyx / enemyy |
X/Y position of the enemy |
bulletx / bullety |
X/Y position of the active bullet |
bullet.active |
Boolean to track if a bullet is in flight |
move_count |
Tracks enemy movement pattern/timing |
The game loop refreshes every 600ms. Each cycle:
- The enemy moves (random actions),
- The bullet (if fired) moves upward,
- Collision checks run,
- LED display is updated.
This project was also ported to Python and Java to showcase logic portability and algorithmic thinking.
Both Python and Java versions include unit tests that validate all core game logic.
- Initial player position
- Player movement (left/right constraints)
- Bullet logic and deactivation
- Bullet collision with enemy
- Game over trigger when enemy reaches the player
The Python implementation (space_invaders.py) is structured as a Game class to facilitate testing with unittest.
Run the game:
python space_invaders.pyThe Java implementation (SpaceInvaders.java) is organized into a modular Game class and includes test coverage using JUnit 5.
Run the game:
javac SpaceInvaders.java
java SpaceInvaders