My recent adventure with Cripple Mr. Onion rekindled my love of making crappy video games, so I decided to give it another try with my latest Arduboy offering – Deep Dish Nine. The goal of this game is to fly pizza delivery missions throughout the TRAPPIST-1 system in the alloted time (or the pizza is free!). This game utilizes the n-body simulation I developed for HANS, and actually requires you to use your knowledge of orbital mechanics to match orbits with your destination planet.
Is that an animated title screen? Get ready to party!
Gameplay
As an inter-planetary pizza deliver person, your role is to pilot your pizza-shaped craft to a randomly selected planet before the countdown timer runs out. You’re navigating through the recently discovered TRAPPIST-1 system, home to seven tightly-spaced planets orbiting a red dwarf approximately 40 light years from Earth. The planetary simulation was originally developed as unnecessarily-accurate desk-art for my office and ran on a Teensy 3.1 microcontroller. The microcontroller powering the Arduboy is significantly worse than the beefy one powering HANS, so the game takes place in a purely 2D universe (not something anyone would actually notice, given how coplanar the planets in the TRAPPIST-1 system are), but otherwise uses the same relatively accurate n-body gravity simulation engine at the heart of HANS. What does that mean for our intrepid pilot? To deliver your pizza on time, you need both an excellent intuitive understanding of orbital mechanics and a lot of patience!
Your mission, should you choose to accept it
The ship itself can be rotated to change its thrust vector, and it has two independent means of propulsion at its disposal. For the very skilled operator, a 3.5 MN main thruster modeled on the Space-X Raptor engine provides a relatively gentle delta-V needed to ensure your pizza gets delivered on time and unscathed. The ship has a starting mass of 2,000 tons, and actually gets lighter as it expends fuel. The ship also possesses a Project Orion-style nuclear-bomb thruster with a payload of 100 warheads (each providing a 100 MN pulse), with the ship similarly getting lighter after each bomb. Your goal is to minimize fuel usage (with a special bonus if you manage not to use the Orion thruster at all), while simultaneously minimizing the time needed to deliver.
The main gameplay screen – we’ve still got 88.5 days to get these pizzas to TRAPPIST-B!
If your ship gets within ‘delivery range’ of your destination planet, the pizza is automatically delivered and your score is tallied. The top three scores are stored in flash on a traditional arcade-style “High Score” board.
Those guys *always* manage to win arcade games somehow
Fancy Graphics
The Arduboy has a 128×64 monochrome screen, so coming up with any kind of interesting graphics for a game that, by definition, mostly involves empty space can be quite a challenge. The ship is just a simple triangle, with the planets and sun being circles. As an aid to our intrepid pilot, the target planet is drawn solid, and the sun is a bit dynamic just for fun. There are three slightly fancy embellishments worth mentioning:
- Dynamic display scaling – We’re dealing with (literally) astronomically large distances, and we have a very tiny screen to work with. The display gets dynamically scaled to just include the orbits of the spaceship and the target planet, and the planet sizes get scaled accordingly. If you’re targeting TRAPPIST-B (the innermost planet), you get to zoom in quite a bit. If you misjudge your slingshot pass around the sun and wind up flung off into the far reaches of space, everything gets quite tiny! This works pretty well in practice, and I was quite proud of it.
- Orbital Trails – As a general guide when slowly converging your orbit with the target planet, both your ship and the target planet leave ephemeral ‘history’ trails showing where they’ve been. You can use these to be a little more precise when lining up orbits. Unfortunately, these don’t automatically scale when the display changes, so they can be a little confusing if you’re rapidly expanding your orbit.
- Velocity Gauges – Your velocity in X and Y dimensions is displayed via thin lines emanating out of the middle of the top and left sides of the screen, respectively. These provide an additional aid to help you fine-tune your orbit.
Configuration Options
The game actually has a few configuration options to make it easier/harder (and it automatically adjusts your score accordingly – harder settings = higher score):
- Time Limit: You can choose a deadline of 30, 60 or 90 days to deliver your pizza
- Delivery Range: You’ll need to get your ship within 0.001, 0.0025 or 0.005 AU of your destination planet to successfully deliver your pizza.
- Timestep (dt): The simulation can use a timestep (the elapsed time in our simulated universe between frames) of 60, 90 or 180 seconds. The game seems to run around 30 FPS, so that means that each second of wall clock time corresponds to 30 minutes, 45 minutes, or 1.5 hours of simulated time. With a 60 second dt and a 90 day time limit, you have 72 minutes of wall-clock time to deliver your pizza. With a 180 second dt and a 30 day time limit, you have only 8 minutes.
Bumps in the Road
As much as I enjoy the Arduboy as a gaming platform, it’s definitely still got some rough edges. When developing Cripple Mr. Onion, I somehow managed to overwrite the (unfused?) bootloader and brick my device. They mailed me a new one, but it was quite frustrating. This time, I somehow managed to make a program (using maybe ~80% of flash/ram) that overwrote the memory location used by the bootloader’s interrupt service routine, meaning that my device, while not bricked, became un-programmable. This caused me to shelve this project (at ~90% completion) for about two months until I found the time to build an In-System Programmer, disassemble my Arduboy and solder leads to the tiny ISP pads. A newer version of the Arduboy2 library apparently fixes this (and I haven’t encountered it again), but it was still extremely frustrating. The device is plenty of fun, but definitely -1 for quality. I’ve never been able to brick another arduino device (including the PJRC Teensy 2.0, which uses the same Atmel 32U4 as the Arduboy!), and I’ve managed to brick my Arduboy both times I’ve tried to make games for it. Anyway, it seems to be working fine for now, so I’ll count my blessings.
See it in action
Check out the gameplay for yourself. With a small timestep it can be fairly relaxing to play, as minor periodic tweaks to your trajectory (spaced every few minutes of wall clock time) can be all that’s needed to hit your target. I’m playing with the largest timestep just to speed things up for the video (and you can see me accidentally slingshotting out of the solar system and needing to blast my way back using my Orion thruster). The game works pretty well in both ‘fast’ and ‘slow’ modes, depending on your mood (and how long you have to play).
Get it for yourself
If you’ve got an Arduboy, load it up and give it a spin! Source code is included if you’d like to play around with it as well.
Get deep_dish_nine.zip (rename to *.arduboy to use with an arduboy game manager)
Conclusion
I first got HANS up and running on my desk in the fall of 2015, and something that had idly crossed my mind many times was what it would be like to fly around in my tiny simulated universe – Deep Dish Nine does a pretty good job answering that question. It’s actually pretty fun to play – in a watching-paint-dry-on-a-nice-day sort of way. I daresay, it’s the most fun you can have with an n-body simulation running on a 16 MHz processor. If you can, give it a shot and let me know what you think!