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
Diff: Menu/Menu.cpp
- Revision:
- 29:bdc4138b5171
- Parent:
- 27:c920c5ec31af
--- a/Menu/Menu.cpp Tue May 07 08:39:38 2019 +0000 +++ b/Menu/Menu.cpp Tue May 07 17:21:00 2019 +0000 @@ -91,6 +91,7 @@ Menu::~Menu() {} void Menu::init() { + // Starting setup of menu. _state = 1; // Starting state is the menu. _controller.init(); // Initialise counters for musical tune. @@ -113,11 +114,11 @@ void Menu::output(N5110 &lcd, Gamepad &gamepad) { // 0, 1 and 2 have been assigned to the output of each state respectively. if (_output == 0) { - run_game(lcd, gamepad); + run_game(lcd, gamepad); // Runs the main game loop. } else if (_output == 1) { - display_menu(lcd, gamepad); + display_menu(lcd, gamepad); // Displays the main menu. } else { - display_controls(lcd, gamepad); + display_controls(lcd, gamepad); // Displayes the control page. } } @@ -139,6 +140,7 @@ } void Menu::display_controls(N5110 &lcd, Gamepad &gamepad) { + // Print lines for aesthetics, and print controls text. lcd.drawLine(0,0,84,0,FILL_BLACK); lcd.drawLine(0,6,84,6,FILL_BLACK); lcd.drawLine(0,24,84,24,FILL_BLACK); @@ -149,10 +151,11 @@ lcd.printString("Collect Coins!",0,5); lcd.printString("A:",0,3); lcd.printString("-Jump",0,4); - play_tone(gamepad); + play_tone(gamepad); // Play the tune. } void Menu::display_menu(N5110 &lcd, Gamepad &gamepad) { + // Print lines and sprite for aesthetics, and print menu text. lcd.drawLine(0,0,84,0,FILL_BLACK); lcd.drawLine(0,6,84,6,FILL_BLACK); lcd.drawLine(0,24,84,24,FILL_BLACK); @@ -160,7 +163,7 @@ lcd.printString("START- Play!",0,1); lcd.printString("X- Controls",0,2); lcd.drawSprite(1,25,23,80,(int*)menu_sprite); - play_tone(gamepad); + play_tone(gamepad); // Play the tune. } void Menu::play_tone(Gamepad &gamepad) { @@ -199,9 +202,10 @@ } void Menu::play_chord_b(Gamepad &gamepad) { + // Same as play_chord_a, just different notes. if (_tone_counter < 5) { if (_tone_flag) { - gamepad.tone(174.61, 0.5); + gamepad.tone(174.61, 0.5); } else { gamepad.tone(349.23, 0.1); }