Title Screen Code

Libraries, utilities, bootloaders...

Title Screen Code

Postby Skyrunner65 » 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: Select all
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: Select all
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: Select all
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.
User avatar
Skyrunner65
 
Posts: 371
Joined: Thu Mar 20, 2014 5:37 pm
Location: NC,USA

Re: Title Screen Code

Postby rodot » Mon Apr 27, 2015 5:18 pm

Hey,

Why don't use use the default titleScreen() function ?
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

Re: Title Screen Code

Postby Skyrunner65 » 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.
User avatar
Skyrunner65
 
Posts: 371
Joined: Thu Mar 20, 2014 5:37 pm
Location: NC,USA


Return to Software Development

Who is online

Users browsing this forum: No registered users and 18 guests

cron