Last January I spied an Arstechnica article, "1D Pac-Man is the best game I’ve played in 2024 (so far)", and it got me thinking. I've done more than a few little arcade games with my Pybadge - but I wondered if I could do something on the CircuitPlayground.... Hmmmm.....
So I came up with StarFighter Patrol. Basic premise: Hyperspace lanes are plagued by navigational hazards - asteroids - that you need to blast to clear for safe passage. A "lane" is a 100 element array in the program - on the CPX you see ten elements - your ship at pixel 4 or 5 (depending on which direction you are heading). The stars and asteroids move clockwise initially - the lane is a circle, if you wait long enough the same elements will come toward you.
Pressing B reverses direction, A fires your lasers. You need to clear the purple asteroids that are a hazard to hyperspace navigation. You can move to a new region by hitting A4. Or if you choose restart the game with A3. When you've been hit 5 times your score (number of asteroids cleared) will show before the game restarts. (the score is digit-by-digit, so 13 would show one pixel, then three pixels. Zero is all green pixels). In the CircuitPython version you restart when you hit A or B. The Makecode/Javascript version will restart after a pause.
The Circuit Playground display shows your spaceship as a green dot, and the stars and asteroids heading toward you in a 10 pixel-wide display - this is a portion of the 100 pixel wide hyperspace lane you patrol (think of the "lane" as a circle - you move left or right in in and will wrap all the way around if you play long enough). Your ship fires toward oncoming objects - so when you reverse course the laser blasts (yellow dots) move towards the oncoming objects.
Bonus: You can see MORE pixels if you attach https://www.adafruit.com/product/3811 - the 30 pixel Adafruit neopixel strip using A1 as the control - then you'll get a 30 pixel wide one-dimensional display!
I'm happier with the way the CircuitPython version turned out - but both versions (Makecode/Javascript or CircuitPython) pretty much work the same.
Switch to the right to turn off sound.
Files in the github archive:
- bach.py - provides musical tones - copy to Circuit Playground for starfighter.py
- starfighter.py - 1D starfighter patrol game. Destroy asteroid threats. copy to code.py on your Circuit Playground
- starfighter.js - Javascript version Makecode link: https://makecode.com/_RocF4AHbY19R
Game controls:A - fire laser B - reverse direction A4 - hyperspace A3 - restart game A7 - show last score
Now, go clear those hyperspace lanes!!!
This page (Is that a good idea? Building a one-dimensional Starfighter game....) was last updated on August 11, 2024.
Text editor powered by tinymce.