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
#include <Arduboy.h>
Arduboy arduboy;
to
#include <Arduboy2.h>
Arduboy2 arduboy;
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.
For example:
Change
arduboy.print("PRESS ANY KEY");
to
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.
For example:
Change:
digitalWrite(RED_LED, LOW);
to
arduboy.digitalWriteRGB(RED_LED, RGB_ON);
There’s also the three parameter version of digitalWriteRGB(), which will set all three LEDs at the same time, so
digitalWrite(RED_LED, HIGH);
digitalWrite(GREEN_LED, HIGH);
digitalWrite(BLUE_LED, LOW);
can become
arduboy.digitalWriteRGB(RGB_OFF, RGB_OFF, RGB_ON);
At the end of setup() you have
Serial.begin(9600);
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)