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.