Libraries, utilities, bootloaders...
Post a reply

Title Screen Code

Mon Apr 27, 2015 4:22 pm

So, some of you MAY have heard of my Title Screen Code. You probably don't want to extract it from my Smash and Crash code, so I'm posting it here.
The majority of the code:
Code:
void titlescreen(){
  while(1){
    if (gb.update()){
      gb.display.drawBitmap(0, 0, logo);
      if (gb.buttons.pressed(BTN_A)){
        gb.sound.playOK();
        gb.battery.show = false;
        break;
        break;
      }
      if (gb.buttons.pressed(BTN_UP)){
        gb.sound.setVolume(1);
        gb.sound.playOK();
      }
      if(gb.buttons.pressed(BTN_DOWN)){
        gb.sound.playCancel();
        gb.sound.setVolume(0);
      }
      if (gb.buttons.pressed(BTN_C)){
        gb.changeGame();
      }
    }
  }
}


If you want to call on it, here is an example:
Code:
void setup(){
  gb.begin();
  titlescreen();
}


That starts the game and displays the title screen. Don't worry, it can be broken out of.
But say you want it in a Menu. That's cool. Here's another example:
Code:
void loop(){
  gb.battery.show = false;
  switch(gb.menu(menu, MENULENGTH)){
    case -1: //nothing selected
      titlescreen();
      break;
    case 0: //Load Game
      //Put your starting code here, or whatever.
      break;
    case 1: //Back to the Loader
      gb.changeGame(); //You could change this to titlescreen();
      break;
  }
}


The Controls for it are as follows:
  • Press Down to mute.
  • Press Up to mute.
  • A goes to the loop.
  • C changes the game.

I hope you enjoy my code.

Re: Title Screen Code

Mon Apr 27, 2015 5:18 pm

Hey,

Why don't use use the default titleScreen() function ?

Re: Title Screen Code

Mon Apr 27, 2015 5:52 pm

Well, it can really only show logos up to 64*30.
Also, I'm not sure about animated images.
Rodot, I'm not criticizing your title screen. It's great.
This is just for the people who want a fully custom Title Screen, and is really more of an example.
Post a reply