A-Maze a game of random generated mazes

(Scott R) #1

Once again I have ported one of Alojz Jakob’s (the guy behind Tamaguino) games to the Arduboy and am grateful that he has included it as part of his main repo.

The game features a series of random generated mazes


Ino & Repo

Original Arduino Project page

Instructable Page

I’m a little torn between using Pressed() and justPressed() as one allows more accuracy in movement whilst the other allows dashing. maybe setting a framerate will solve the issue of over dashing with justpressed()?
Added hex and set framerate to reduce player over run at junction when using justPressed().

(Scott) #2

You could consider adding a delay after the first press of a button before it starts auto repeating (like PC keyboards do). This way you can be as precise as you want with single presses and as fast as you want once repeating starts.

You can look at the SetSystemEEPROM and RGBled example sketches in the Arduboy2 library for an example of doing this.


This week I wrote some prototyping button debounce and repeat code for my custom bootloader. Maybe it can be of help.

#include <Arduboy2.h>

Arduboy2  arduboy;
uint8_t ButtonsDebounceState;
uint8_t buttonsDebounceDelay;
uint8_t buttonsRepeatDelay;
uint8_t oldButtonsState;
uint8_t ButtonsState;

bool red_on, blue_on;

#define BUTTON_DEBOUNCE_DELAY 10  //time for button states to stabelize
#define BUTTON_REPEAT_DELAY   250 //time before buttons start to repeat
#define BUTTON_REPEAT_SPEED   125 //button repeat interval

void setup()

void loop() 
 arduboy.delayShort(1); //using 1 msec per loop timing interval
 uint8_t currentButtonsState = arduboy.buttonsState();
 if (currentButtonsState == ButtonsDebounceState)
  if (buttonsDebounceDelay > 0) //still in debounce timeout period
  else //// debounce timeout expired, buttons state is stable ////
    if (currentButtonsState == oldButtonsState) //no changes, check autorepeat
      if (buttonsRepeatDelay > 0) //still in repeat timeout period
        ButtonsState = 0;
      else //repeat timeout expired, repeat button
        ButtonsState = oldButtonsState;
        buttonsRepeatDelay = BUTTON_REPEAT_SPEED;
    else //pressed buttons changed
      ButtonsState = (~oldButtonsState) & currentButtonsState;
      oldButtonsState = currentButtonsState;
      buttonsRepeatDelay = BUTTON_REPEAT_DELAY;
  } //////////////////////////////////////////////////////////  
 else //still bouncing
  ButtonsDebounceState  = currentButtonsState;
  buttonsDebounceDelay = BUTTON_DEBOUNCE_DELAY;
 //some test code, toggle LED states
 if (ButtonsState & A_BUTTON) red_on = !red_on;
 if (ButtonsState  & B_BUTTON) blue_on = !blue_on;
 //control LEDs
 if (red_on) arduboy.digitalWriteRGB(RED_LED, RGB_ON); else arduboy.digitalWriteRGB(RED_LED, RGB_OFF);
 if (blue_on) arduboy.digitalWriteRGB(BLUE_LED, RGB_ON); else arduboy.digitalWriteRGB(BLUE_LED, RGB_OFF);

(Scott R) #4

I forgot to update this but there are now four game modes and battery monitor. the battery monitor works but could do with some improvements
you can grab the latest here:

video of new modes

i’ll update first post one pull request done.

(Josh Goebel) #5

Where is the code for displayBattery?

(Scott R) #6

In the main .ino readVcc() it could be improved a lot even though I got it close to my multimeter with the -249