Ahmed Adamjee
/
SnakeVSBlock
Snake vs Block Game to be run upon K64F.
Diff: Settings/Settings.cpp
- Revision:
- 5:e4df87957a5b
- Child:
- 6:3ffab44ed49c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Settings/Settings.cpp Wed Mar 20 11:41:18 2019 +0000 @@ -0,0 +1,98 @@ +#include "Settings.h" + +Settings::Settings() +{ + +} + +Settings::~Settings() +{ + +} + +void Settings::info(N5110 &lcd, Gamepad &pad) +{ + lcd.clear(); + pad.leds_on(); + lcd.printString("For selecting",0,0);//Function used to promt the user to how to use settings. + lcd.printString("from settings",0,1); + lcd.printString("available, use",0,2); + lcd.printString("Joystick in <>",0,3); + lcd.printString("directions",0,4); + lcd.refresh(); + wait(2); + lcd.clear(); + lcd.printString("For adjusting",0,0); + lcd.printString("the parameters,",0,1); + lcd.printString("use the pot",0,2); + lcd.printString("by rotating",0,3); + lcd.printString("Press Back",0,4); + lcd.printString("to confirm",0,5); + lcd.refresh(); + wait(2); + pad.leds_off(); + lcd.clear(); +} + +float Settings::controlSensitivity(N5110 &lcd, Gamepad &pad) +{ + lcd.printString("Control Speeds",0,0); + float cs; + cs = pad.read_pot()*6+1; + lcd.drawRect(15,22,54,13,FILL_TRANSPARENT); + lcd.drawRect(15,22,pad.read_pot()*54,13,FILL_BLACK); + pad.leds_on(); + return cs; +} + +void Settings::brigntness(N5110 &lcd, Gamepad &pad) +{ + lcd.printString("Brigntness",9,0); + float pot; + pot = pad.read_pot(); + lcd.drawRect(15,22,54,13,FILL_TRANSPARENT); + lcd.drawRect(15,22,pad.read_pot()*54,13,FILL_BLACK); + lcd.setBrightness(pot); + pad.leds_on(); +} + +void Settings::contrast(N5110 &lcd, Gamepad &pad) +{ + lcd.printString("Contrast",16,0); + float pot; + pot = (pad.read_pot()+1)/3; + lcd.drawRect(15,22,54,13,FILL_TRANSPARENT); + lcd.drawRect(15,22,pad.read_pot()*54,13,FILL_BLACK); + lcd.setContrast(pot); + pad.leds_on(); +} + +void Settings::volume(N5110 &lcd, Gamepad &pad) +{ + lcd.printString("Volume",20,0); + float pot; + pot = pad.read_pot(); + lcd.drawRect(15,22,54,13,FILL_TRANSPARENT); + lcd.drawRect(15,22,pot*54,13,FILL_BLACK); + pad.leds_on(); +} + +int Settings::showCredits(N5110 &lcd, Gamepad &pad) +{ + lcd.printString("Show Credits?",5,0); + float pot; + int show = 1; + pot = pad.read_pot(); + + if((0.1<=pot<=0.2)||(0.3<=pot<=0.4)||(0.5<=pot<=0.6)||(0.7<=pot<=0.8)||(0.9<=pot)) { + lcd.printString("NO",36,3); + show = 0; + } + + else if((pot<0.1)||(0.2<pot<0.3)||(0.4<pot<0.5)||(0.6<pot<0.7)||(0.8<pot<0.9)) { + lcd.printString("YES",33,3); + show = 1; + } + pad.leds_on(); + return show; +} \ No newline at end of file