When I have time I’d like to push this closer and closer to being a “clone”, but for now it’s a straightforward shooter, except you rotate around the center and shoot towards the middle. Enemies emerge from the “portal” in the middle.
High score is saved in EEPROM (only if the first five bytes are
'T', 'M', 'P', 'S', 'T').
I suggest you use EEPROM.update() instead of EEPROM.write(). Or, you may wish to consider using EEPROM.get() and EEPROM.put() to simplify your code.
@colinta, Is there a reason you’ve disabled the boot logo? Why not just use
No not any reason in particular, I started out by looking at the source code for tiny 2048, which boots directly into the game, so I was going for the same thing. Having the boot screen is fun, though!
And note that even when enabled, for those in a hurry the boot logo sequence can be bypassed or exited by pressing the RIGHT button.
Why not use a switch statement for changing the game state?
The reason I didn’t? Because I started with just two states, then I added one more, then by the time I added the rest I had a longer if. Plus I don’t like C-style switch statements, the fallthrough behavior and weird scoping made me prefer multiple ifs long long long ago. Too late to change now!
FWIW I do enjoy Elixir’s equivalent, the
case keyword, and Swift’s, too, which guarantees completeness and doesn’t have implicit fallthrough.
I actually prefer the style where the game states are stored as a list of function pointers, and the function pointer is called by index
Good call - just updated the code. And using
EEPROM.get/put makes that
uint16_t much easier!