Coin Rush! (First Arduboy Game)

CoinRush.hex (28.7 KB)

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 :slightly_smiling_face:. Thanks to everyone who helped me with the coding, especially @Pharap and @filmote !

5 Likes

Really nice!
Fun and quick to play. Thanks for sharing :slight_smile:
Could the cars wrap around the screen, rather than disappearing?

1 Like

Not sure how do to that, good idea though. Iโ€™ll keep tinkering and find a way :slightly_smiling_face:

Glad to see you managed to incorporate the delay state and some of my other suggested changes.
(It would be nice to see the others included at some point too though.)

The simplest way is just something like:

constexpr int carMinX = -carWidth;
constexpr int carMaxX = (arduboy.width() + carWidth);

if(carX <= carMinX)
  carX = carMaxX;
else if(carX >= carMaxX)
  carX = carMinX;

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.

1 Like

Nice little game!

Great work.

2 Likes