![](/media/cache/profiles/LinkedIn_0NghoZJ.jpeg.50x50_q85.jpg)
Snake vs Block Game to be run upon K64F.
Diff: MenuClasses/Settings/Settings.cpp
- Revision:
- 89:8fbb0405a916
- Parent:
- 83:329da564799a
--- a/MenuClasses/Settings/Settings.cpp Wed May 08 18:20:23 2019 +0000 +++ b/MenuClasses/Settings/Settings.cpp Wed May 08 19:05:30 2019 +0000 @@ -80,38 +80,38 @@ { _lcd = lcd; _pad = pad; + cs_sc[0] = 4; //to initialise the control speeds + cs_sc[1] = 1; //to set show credits to a default of 1. + settingsIndex = 1; //an index for settings } -float * Settings::Implement(float cs) +float * Settings::Implement(float controlSensitivity) { Settings::info(); - cs_sc[0] = 4; //to initialise the control speeds - cs_sc[1] = 1; //to set show credits to a default of 1. - int st = 1; //an index for settings - wait(1/cs); //to avoid a race condition of the following while loop being skipped. + wait(1/controlSensitivity); //to avoid a race condition of the following while loop being skipped. //_pad->init(); while (_pad->check_event(Gamepad::BACK_PRESSED) == false) { //if button pressed. Direction d = _pad->get_direction(); - wait(1/cs); + wait(1/controlSensitivity); _lcd->clear(); - if((d==E)&&(st==4)) { - st=1; + if((d==E)&&(settingsIndex==4)) { + settingsIndex=1; } - else if((d==W)&&(st==1)) { - st=4; + else if((d==W)&&(settingsIndex==1)) { + settingsIndex=4; } - else if((d==E)&&(1<=st<=3)) { - st=st+1; + else if((d==E)&&(1<=settingsIndex<=3)) { + settingsIndex=settingsIndex+1; } - else if((d==W)&&(2<=st<=4)) { - st=st-1; + else if((d==W)&&(2<=settingsIndex<=4)) { + settingsIndex=settingsIndex-1; } - Settings::CallFunctions(st); + Settings::CallFunctions(settingsIndex); } _pad->tone(1000.0,0.1); return cs_sc; @@ -140,12 +140,12 @@ _pad->leds_off(); } -void Settings::CallFunctions(int st) +void Settings::CallFunctions(int settingsIndex) { _lcd->clear(); _lcd->drawSprite(5,22,13,8,(int *)naviL); //Function used to draw the sprite. _lcd->drawSprite(71,22,13,8,(int *)naviR); //Function used to draw the sprite. - switch (st) { + switch (settingsIndex) { case 1: Settings::controlSensitivity(); break;