My first MAKERbuino demo

Here is a little demo I’ve made. It’s an animated sprite which you move with the D-Pad. Pressing A+B causes the animation to pause. Then you can advance or rewind frames by pressing A and B respectively. By pressing both, the animation is resumed. I coded the sprite bitmap manually after designing it in Paint.NET. Please tell me what you think.
platformGuy

#include <SPI.h>
#include <Gamebuino.h>
Gamebuino gb;

const byte platformGuy_frame1[] PROGMEM = {8,10,
                             B00111110,
                             B01001010,
                             B01000001,
                             B00100110,
                             B00111100,
                             B00101000,
                             B00111000,
                             B00101000,
                             B00100100,
                             B00111100};

const byte platformGuy_frame2[] PROGMEM = {8,10,
                             B00111110,
                             B01001010,
                             B01000001,
                             B00100110,
                             B00111100,
                             B00110111,
                             B00111101,
                             B01011001,
                             B01001111,
                             B01111000};

const byte platformGuy_frame3[] PROGMEM = {8,10,
                             B00111110,
                             B01001010,
                             B01000001,
                             B00100110,
                             B00111100,
                             B00110100,
                             B11111100,
                             B10010100,
                             B10110010,
                             B11111110};

const byte* const platformGuy_spritesheet[] PROGMEM =
{
  platformGuy_frame1,
  platformGuy_frame2,
  platformGuy_frame3
};

void setup()
{
  gb.begin();
  gb.titleScreen(F("myBitmap"));
}

uint8_t bmp_x=LCDWIDTH/2;
uint8_t bmp_y=LCDHEIGHT/2;
uint8_t frame_counter=0;
uint8_t frame_last=2;
uint8_t anim_timer=0;
uint8_t anim_speed=4;
bool anim_run=true;

void loop()
{
  if(gb.update())
  {
    if(gb.buttons.repeat(BTN_RIGHT,1))
    {
      bmp_x++;
    }
    if(gb.buttons.repeat(BTN_LEFT,1))
    {
      bmp_x--;
    }
    if(gb.buttons.repeat(BTN_UP,1))
    {
      bmp_y--;
    }
    if(gb.buttons.repeat(BTN_DOWN,1))
    {
      bmp_y++;
    }
    if(anim_run)
    {
      if(gb.buttons.repeat(BTN_A,1))
      {
        if(gb.buttons.pressed(BTN_B))
        {
          anim_run=false;
        }
      }
      if(gb.buttons.repeat(BTN_B,1))
      {
        if(gb.buttons.pressed(BTN_A))
        {
          anim_run=false;
        }
      }
      if(anim_run)
      {
        if(++anim_timer>=anim_speed)
        {
          if(frame_counter++==frame_last)
          {
            frame_counter=0;
          }
          anim_timer=0;
        }
      }
    }
    else
    {
      if(gb.buttons.pressed(BTN_A))
      {
        if(frame_counter++==frame_last){frame_counter=0;}
      }
      if(gb.buttons.pressed(BTN_B))
      {
        if(frame_counter--==0){frame_counter=frame_last;}
      }
      if(gb.buttons.repeat(BTN_A,1))
      {
        if(gb.buttons.pressed(BTN_B))
        {
          anim_run=true;
        }
      }
      if(gb.buttons.repeat(BTN_B,1))
      {
        if(gb.buttons.pressed(BTN_A))
        {
          anim_run=true;
        }
      }
    }
    gb.display.drawBitmap(bmp_x, bmp_y, (byte*)pgm_read_word(&platformGuy_spritesheet[frame_counter]));
    if(gb.buttons.pressed(BTN_C))
    {
      gb.titleScreen(F("myBitmap"));
    }
  }
}
3 Likes

@Zvoc47, congratulations, this looks neat. It’d be great if you could post a GIF of your program in action.

I’m not sure how to make a GIF out of my game. Is there a program to do that?

@Zvoc47, Simbuino for Windows is an emulator which can record into gif format with the F12 key.

http://legacy.gamebuino.com/wiki/index.php?title=Emulators

Don’t use the 4Web version as it doesn’t have a record function.
Once you load the .hex file into Simbuino, start the program under ‘Debug’ then press F12 to start recording, then F12 again to stop.

Controls:
W,A,S,D = Up Left Down Right (Respectively)
K, L = A, B button
R = C Button

1 Like