A-Maze a game of random generated mazes

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

ArduboyRecording%20(2)

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()?
Edit:
HEX & INO
Added hex and set framerate to reduce player over run at junction when using justPressed().

6 Likes

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.

2 Likes

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
  {
    buttonsDebounceDelay--;
  }
  else //// debounce timeout expired, buttons state is stable ////
  {
    if (currentButtonsState == oldButtonsState) //no changes, check autorepeat
    {
      if (buttonsRepeatDelay > 0) //still in repeat timeout period
      {
        buttonsRepeatDelay--;
        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);
}
2 Likes

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.

8 Likes

Where is the code for displayBattery?

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

Hey @Keyboard_Camper I just checked but I didn’t see a hex file in there, is there one available?