Anyone who has seen the miniature 3D printed Trek and Star Wars ships hanging over my workbench (thanks, Thingiverse!) won't be surprised how many of my projects take an SF bent. But I've also got a space station!
And that inspires this Circuit Playground Express project - launching probes into the Bajoran Worhmhole!
I've got a repository for the code at DS9-game:
There are three files, two CircuitPython, and one JavaScript (or you can follow the makecode.com link)
- ds9.js - Javascript/Makecode version of game (https://makecode.com/_KhmDoYXCpVdh)
- ds9.py - CircuitPython version (rename to code.py)
- bach.py - helper code for music and sounds for ds9.py
It is a pretty simple game using the Circuit Playground circle of neopixels.
The premise is the space station Deep Space Nine (a blue neopixel) is in motion near the Bajoran Wormhole (a neopixel of shifting color). As the station shifts back and forth, the wormhole remains the same distance (five neopixels away). The station is launching automated probes to the wormhole - A sends them counter-clockwise, B sends them in a clockwise direction. You have ten probes to launch - if they successfully enter the wormhole, there will be a rainbow of neopixels across all ten. When you have sent all ten, you'll see pixels representing how many you managed to send into the wormhole (0-10). For the Makecode version, shake the CPX to restart. For the CircuitPython version press A or B.
Both versions make a sound when launching the probe, and will play a scale or musical flourish when you succeed. To turn that off, slide the switch to the left. To the right turns the game sounds on.
I found the differences in coding Makecode and CircuitPython versions interesting. With Makecode I could have multiple "forever" loops handling different actions - toggling Booleans to activate/deactivate them. With CircuitPython I used a single game loop and controlled the movement of the probe with a Boolean and a counter (it can only go 4 steps). The same Boolean prevents the A/B buttons from launching more than one probe at a time.
Give it a try - see how many you can get to land in the wormhole!
This page (Launching from DS9!!!) was last updated on September 23, 2024.
Text editor powered by tinymce.