I suggest you switch to using the Arduboy2 library. The original Arduboy library is no longer being maintained. Arduboy2 is recommended for new game development. This will free up more program space (for more levels if you wish).
To do this for your game you just have to make sure the Arduboy2 library is installed and change
I also suggest you add the F() macro to all of your arduboy.print() calls that print a fixed string. The F() macro allows the string to exist only in program memory instead of the compiler needing to create a copy in RAM. This will save RAM space and, for your game, will eliminate the
Low memory available, stability problems may occur.
warning that you get.
arduboy.print("PRESS ANY KEY");
arduboy.print(F("PRESS ANY KEY"));
The Arduboy2 library provides the digitalWriteRGB() functions to control the RGB LED digitally. You can use these instead of the digitalWrite() calls, which will save a fair amount of program memory. You also don’t need to use the pinMode() functions, the library will set the RGB LED pins properly.
There’s also the three parameter version of digitalWriteRGB(), which will set all three LEDs at the same time, so
arduboy.digitalWriteRGB(RGB_OFF, RGB_OFF, RGB_ON);
At the end of setup() you have
Serial.print("\n\n Arduboy launched \n\n");
that you were using for debugging. You can comment these lines out in the released version, to save some program space.
I didn’t look at the cause, but your game creates some compiler warnings when “verbose warnings” is turned on. You may wish to address these warnings
To see them, from the IDE menus select
File > Preferences
and then set the checkbox for
Show verbose output during: compilation
(You don’t have to worry about the warnings related to EEPROM.)
I made the above changes to your game and saved 2498 bytes of program memory and 501 bytes of RAM.
I put my version in a GitHub Gist (I may delete it at some point in the future, so the following link might be broken)