Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
StartMenu/StartMenu.cpp
- Committer:
- ll17lrc
- Date:
- 2020-05-26
- Revision:
- 13:fd290d2fd917
- Parent:
- 12:299479b6bb59
File content as of revision 13:fd290d2fd917:
#include "StartMenu.h"
StartMenu::StartMenu()
{
}
StartMenu::~StartMenu()
{
}
//start menu
void StartMenu::complete(Gamepad &pad,N5110 &lcd)
{
ImpossEngine imposs;
//stores position of the pointer
int selector = 1;
//sprite to store the arrow used as an indicator on the menu
int arrow[7][5] = {
{0,0,0,0,0},
{1,1,0,0,0},
{1,1,1,1,0},
{1,1,1,1,1},
{1,1,1,1,0},
{1,1,0,0,0},
{0,0,0,0,0},
};
//displays start menu until A is pressed
while( pad.A_pressed() == false ){
//draws the start menu
lcd.clear();
lcd.printString(" IMPOSSIBLE ",0,1);
lcd.printString(" Start Game ",0,3);
lcd.printString(" How to play ",0,4);
lcd.drawSprite(5,16 + (selector * 8),7,5,(int *)arrow);
lcd.refresh();
wait(0.15);
//updates the position of the indicator
if( pad.get_direction() == S ){
if( selector < 2 ){
selector ++;
}
}
//updates the position of the indicator
if( pad.get_direction() == N ){
if( selector > 1 ){
selector --;
}
}
}
//starts the game
if( selector == 1 ){
imposs.set_level_zero();
}
//explains how the game works, each screen is displayed until A is pressed
if( selector == 2 ){
wait(0.15);
while(pad.A_pressed() == false){
lcd.clear();
lcd.printString("Use the ",0,0);
lcd.printString("joystick to ",0,1);
lcd.printString("move the ball.",0,2);
lcd.drawSprite(70,40,7,5,(int *)arrow);
lcd.refresh();
}
while(pad.A_pressed() == false){
wait(0.15);
lcd.clear();
lcd.printString("Press A to ",0,0);
lcd.printString("double your ",0,1);
lcd.printString("speed! ",0,2);
lcd.drawSprite(70,40,7,5,(int *)arrow);
lcd.refresh();
}
while(pad.A_pressed() == false){
wait(0.15);
lcd.clear();
lcd.printString("Touch a wall ",0,0);
lcd.printString("and you fail! ",0,1);
lcd.printString("There are 6 ",0,2);
lcd.printString("levels. ",0,3);
lcd.printString("Good luck! ",0,4);
lcd.drawSprite(70,40,7,5,(int *)arrow);
lcd.refresh();
}
//Starts the game after each screen has been displayed
imposs.set_level_zero();
}
}