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.
Diff: Menu/Menu.cpp
- Revision:
- 14:a57a40ff9430
- Parent:
- 13:81573be8fac6
- Child:
- 15:130900e5c268
--- a/Menu/Menu.cpp Mon May 07 19:41:09 2018 +0000 +++ b/Menu/Menu.cpp Tue May 08 13:15:41 2018 +0000 @@ -33,6 +33,16 @@ void Menu::update() { //moves arrow around menus + moveArrow(); + + //selects item in menu + if (_buttonPressed) { + selectItem(); + } +} + +void Menu::moveArrow() +{ if (_menuScreen == "main" ) { if (_d == N && _mainSelection > 1) { //checks the menu arrow location _mainSelection -= 1; @@ -52,41 +62,40 @@ _lvlSelection += 1; } } +} - //selects item in menu - if (_buttonPressed) { - if (_menuScreen == "main" ) { - if (_mainSelection == 1) { - _start = true; - } else if (_mainSelection == 2) { - _menuScreen = "lvl"; - } else if (_mainSelection == 3) { - _menuScreen = "dif"; +void Menu::selectItem() +{ + if (_menuScreen == "main" ) { + if (_mainSelection == 1) { + _start = true; + } else if (_mainSelection == 2) { + _menuScreen = "lvl"; + } else if (_mainSelection == 3) { + _menuScreen = "dif"; + } + } else { + if (_menuScreen == "dif" ) { + if (_difSelection == 1) { + _difficulty = 1; + } else if (_difSelection == 2) { + _difficulty = 2; + } else if (_difSelection == 3) { + _difficulty = 3; + } else if (_difSelection == 4) { + _difficulty = 4; } - } else { - if (_menuScreen == "dif" ) { - if (_difSelection == 1) { - _difficulty = 1; - } else if (_difSelection == 2) { - _difficulty = 2; - } else if (_difSelection == 3) { - _difficulty = 3; - } else if (_difSelection == 4) { - _difficulty = 4; - } - } else if (_menuScreen == "lvl" ) { - if (_lvlSelection == 1) { - _level = 1; - } else if (_lvlSelection == 2) { - _level = 2; - } else if (_lvlSelection == 3) { - _level = 3; - } + } else if (_menuScreen == "lvl" ) { + if (_lvlSelection == 1) { + _level = 1; + } else if (_lvlSelection == 2) { + _level = 2; + } else if (_lvlSelection == 3) { + _level = 3; } + } - _menuScreen = "main"; - - } + _menuScreen = "main"; } } @@ -123,10 +132,10 @@ { 0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0}, { 0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,1,1,1,1,0,0,0,0,0}, { 0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} + { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; - + lcd.drawSprite(10,35,8,40,(int *)_snake); } else if ( _menuScreen == "dif") {