How to code menu and add sprites

I am making a game and i want to create a menu with some options when i press C button, but gamebuino wiki instructions are not clear to me. Can someone please help me with making menu.
Second question: how to add sprites? I know that you need to add bitmap but gamebuino wiki only says how to add it in game, but how to create it(bitmap)?
Thank you

1 Like

Hey Leo,

There are multiple approaches you can take to create a menu in your game. In one of my games (Video Poker), if the C button is pressed it will call a pause menu function which contains its own infinite loop:

  // Button C - Pause Game
  if(gb.buttons.pressed(BTN_C))
  {
    playSound(sndPause, 0);
    pauseGame();
  }

The pause function is as follows:

// Show pause menu
void pauseGame()
{ 
  while(1)
  {
    if(gb.update())
    {
        gb.display.cursorY = 18;
        gb.display.cursorX = 20;
        gb.display.println(F("P A U S E D"));

        gb.display.cursorY = 30;
        gb.display.println(F("A: Title Screen"));
        gb.display.println(F("B: Show Hand Info"));
        gb.display.println(F("C: Resume Game"));
        
        // Button A - Return to Title Screen
        if(gb.buttons.pressed(BTN_A))
        {
          setup();
          return;
        }

        // Button C - Resume Game
        if(gb.buttons.pressed(BTN_C))
        {
          playSound(sndResume, 0);
          return;
        }

        // Button B - Show Hand Info
        if(gb.buttons.pressed(BTN_B))
        {
          showHandInfo();
        }
      }
   }
}

The source code is available here if you want to check it out:
https://github.com/delpozzo/videopoker-gamebuino/blob/master/src/VideoPoker/VideoPoker.ino

Regarding your second question about the sprites, if I remember correctly you can use the Bitmap Encoder utility located here to convert them to code:
http://legacy.gamebuino.com/wiki/index.php?title=Download

3 Likes