[Release] Standardised Pause Function for Arduboy

Hey developers. So we’re all aware that the Arduboy has a limited number of inputs and as such, a pause menu can be hard to implement. I’ve seen a lot of different implementations so I thought I’d have a go at standardising how the button combo for pausing the game on arduboy.
This is that attempt.
While developing Stellar Impact I spent a while testing which button combination would be best for pausing, and I settled on all 4 dpad buttons at once. It’s very unlikely that the player will use this combo in normal play so it can be sensibly reserved for pausing, and since each Dpad direction is a separate button on the arduboy, this approach is viable.

To use this, just copy arduboy-pause-check.h to the folder your project is in, and include it in your work. Hopefully you all find it useful. The check_pause function takes an Arduboy object and a boolean as its parameters.

If you use this, please remember: true is paused, false is unpaused.

I attempted to convert it into a proper arduino library but 1) the arduino compiler was having none of it and 2) I’m not sure people want to deal with a custom class just for this one thing.

In terms of memory, the library uses two bytes, so very little overhead for your project!

Also included is an example program that, when the game is paused, just prints ‘paused’ to 0,0.

Edit: I have put in a pull request for the main arduboy library that integrates this code.

4 Likes

You would be better to pass the Arduboy class parameter to check_pause() by reference. With your pause_check-example.ino sketch it saves 234 bytes and probably speeds things up.

In arduboy_pause_check.h change

bool check_pause(Arduboy arduboy, bool isPaused){

to

bool check_pause(Arduboy& arduboy, bool isPaused){
1 Like

Done. Thanks. :slight_smile: