This is my first Arduboy game, Coin Rush! The objective is simple, move the car around and collect coins, while avoiding the white squares. Your highscore is saved to the EEPROM so every time you play, your high score will still be there . Thanks to everyone who helped me with the coding, especially @Pharap and @filmote !
Though it’s probably better to use the first test only in the case where the car is moving left and the second test only in the case where the car is moving right.
You’d do more or less the same thing for the y axis, but using arduboy.height() instead of arduboy.width(), and carHeight instead of carWidth. (Obviously substitute the variables with whatever would make sense in your case. Probably enemyX, enemyWidth and so forth.)
Two quick tips:
Instead of doing lots of arduboy.print("\n"); in a row, it would be cheaper to group them into a single string, like arduboy.print("\n\n\n");, because the extra function calls use more memory (progmem).
If you wrap your strings in the F macro you can save memory (RAM). E.g. arduboy.print(F("Highscore = "));. Using the F macro only works with the print and println functions though. It works by making sure that the strings are kept in progmem (read-only code and data memory) and not placed in RAM (the kind of read-write data variables and some other stuff get stored in).
Probably not something you’ll be worrying about at the moment, but it certainly helps as your game grows.