![](/media/cache/profiles/LinkedIn_0NghoZJ.jpeg.50x50_q85.jpg)
Snake vs Block Game to be run upon K64F.
Settings/Settings.cpp@6:3ffab44ed49c, 2019-03-23 (annotated)
- Committer:
- AhmedPlaymaker
- Date:
- Sat Mar 23 15:07:15 2019 +0000
- Revision:
- 6:3ffab44ed49c
- Parent:
- 5:e4df87957a5b
- Child:
- 30:461231877c89
Added some tones and animation in Launch
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AhmedPlaymaker | 5:e4df87957a5b | 1 | #include "Settings.h" |
AhmedPlaymaker | 5:e4df87957a5b | 2 | |
AhmedPlaymaker | 5:e4df87957a5b | 3 | Settings::Settings() |
AhmedPlaymaker | 5:e4df87957a5b | 4 | { |
AhmedPlaymaker | 5:e4df87957a5b | 5 | |
AhmedPlaymaker | 5:e4df87957a5b | 6 | } |
AhmedPlaymaker | 5:e4df87957a5b | 7 | |
AhmedPlaymaker | 5:e4df87957a5b | 8 | Settings::~Settings() |
AhmedPlaymaker | 5:e4df87957a5b | 9 | { |
AhmedPlaymaker | 5:e4df87957a5b | 10 | |
AhmedPlaymaker | 5:e4df87957a5b | 11 | } |
AhmedPlaymaker | 5:e4df87957a5b | 12 | |
AhmedPlaymaker | 5:e4df87957a5b | 13 | void Settings::info(N5110 &lcd, Gamepad &pad) |
AhmedPlaymaker | 5:e4df87957a5b | 14 | { |
AhmedPlaymaker | 5:e4df87957a5b | 15 | lcd.clear(); |
AhmedPlaymaker | 5:e4df87957a5b | 16 | pad.leds_on(); |
AhmedPlaymaker | 5:e4df87957a5b | 17 | lcd.printString("For selecting",0,0);//Function used to promt the user to how to use settings. |
AhmedPlaymaker | 5:e4df87957a5b | 18 | lcd.printString("from settings",0,1); |
AhmedPlaymaker | 5:e4df87957a5b | 19 | lcd.printString("available, use",0,2); |
AhmedPlaymaker | 5:e4df87957a5b | 20 | lcd.printString("Joystick in <>",0,3); |
AhmedPlaymaker | 5:e4df87957a5b | 21 | lcd.printString("directions",0,4); |
AhmedPlaymaker | 5:e4df87957a5b | 22 | lcd.refresh(); |
AhmedPlaymaker | 5:e4df87957a5b | 23 | wait(2); |
AhmedPlaymaker | 5:e4df87957a5b | 24 | lcd.clear(); |
AhmedPlaymaker | 5:e4df87957a5b | 25 | lcd.printString("For adjusting",0,0); |
AhmedPlaymaker | 5:e4df87957a5b | 26 | lcd.printString("the parameters,",0,1); |
AhmedPlaymaker | 5:e4df87957a5b | 27 | lcd.printString("use the pot",0,2); |
AhmedPlaymaker | 5:e4df87957a5b | 28 | lcd.printString("by rotating",0,3); |
AhmedPlaymaker | 5:e4df87957a5b | 29 | lcd.printString("Press Back",0,4); |
AhmedPlaymaker | 5:e4df87957a5b | 30 | lcd.printString("to confirm",0,5); |
AhmedPlaymaker | 5:e4df87957a5b | 31 | lcd.refresh(); |
AhmedPlaymaker | 5:e4df87957a5b | 32 | wait(2); |
AhmedPlaymaker | 5:e4df87957a5b | 33 | pad.leds_off(); |
AhmedPlaymaker | 5:e4df87957a5b | 34 | lcd.clear(); |
AhmedPlaymaker | 5:e4df87957a5b | 35 | } |
AhmedPlaymaker | 5:e4df87957a5b | 36 | |
AhmedPlaymaker | 5:e4df87957a5b | 37 | float Settings::controlSensitivity(N5110 &lcd, Gamepad &pad) |
AhmedPlaymaker | 5:e4df87957a5b | 38 | { |
AhmedPlaymaker | 5:e4df87957a5b | 39 | lcd.printString("Control Speeds",0,0); |
AhmedPlaymaker | 5:e4df87957a5b | 40 | float cs; |
AhmedPlaymaker | 6:3ffab44ed49c | 41 | cs = pad.read_pot()*5+1; |
AhmedPlaymaker | 5:e4df87957a5b | 42 | lcd.drawRect(15,22,54,13,FILL_TRANSPARENT); |
AhmedPlaymaker | 5:e4df87957a5b | 43 | lcd.drawRect(15,22,pad.read_pot()*54,13,FILL_BLACK); |
AhmedPlaymaker | 5:e4df87957a5b | 44 | pad.leds_on(); |
AhmedPlaymaker | 5:e4df87957a5b | 45 | return cs; |
AhmedPlaymaker | 5:e4df87957a5b | 46 | } |
AhmedPlaymaker | 5:e4df87957a5b | 47 | |
AhmedPlaymaker | 5:e4df87957a5b | 48 | void Settings::brigntness(N5110 &lcd, Gamepad &pad) |
AhmedPlaymaker | 5:e4df87957a5b | 49 | { |
AhmedPlaymaker | 5:e4df87957a5b | 50 | lcd.printString("Brigntness",9,0); |
AhmedPlaymaker | 5:e4df87957a5b | 51 | float pot; |
AhmedPlaymaker | 5:e4df87957a5b | 52 | pot = pad.read_pot(); |
AhmedPlaymaker | 5:e4df87957a5b | 53 | lcd.drawRect(15,22,54,13,FILL_TRANSPARENT); |
AhmedPlaymaker | 5:e4df87957a5b | 54 | lcd.drawRect(15,22,pad.read_pot()*54,13,FILL_BLACK); |
AhmedPlaymaker | 5:e4df87957a5b | 55 | lcd.setBrightness(pot); |
AhmedPlaymaker | 5:e4df87957a5b | 56 | pad.leds_on(); |
AhmedPlaymaker | 5:e4df87957a5b | 57 | } |
AhmedPlaymaker | 5:e4df87957a5b | 58 | |
AhmedPlaymaker | 5:e4df87957a5b | 59 | void Settings::contrast(N5110 &lcd, Gamepad &pad) |
AhmedPlaymaker | 5:e4df87957a5b | 60 | { |
AhmedPlaymaker | 5:e4df87957a5b | 61 | lcd.printString("Contrast",16,0); |
AhmedPlaymaker | 5:e4df87957a5b | 62 | float pot; |
AhmedPlaymaker | 6:3ffab44ed49c | 63 | pot = ((pad.read_pot()+3.5)/8); |
AhmedPlaymaker | 5:e4df87957a5b | 64 | lcd.drawRect(15,22,54,13,FILL_TRANSPARENT); |
AhmedPlaymaker | 5:e4df87957a5b | 65 | lcd.drawRect(15,22,pad.read_pot()*54,13,FILL_BLACK); |
AhmedPlaymaker | 5:e4df87957a5b | 66 | lcd.setContrast(pot); |
AhmedPlaymaker | 5:e4df87957a5b | 67 | pad.leds_on(); |
AhmedPlaymaker | 5:e4df87957a5b | 68 | } |
AhmedPlaymaker | 5:e4df87957a5b | 69 | |
AhmedPlaymaker | 5:e4df87957a5b | 70 | void Settings::volume(N5110 &lcd, Gamepad &pad) |
AhmedPlaymaker | 5:e4df87957a5b | 71 | { |
AhmedPlaymaker | 5:e4df87957a5b | 72 | lcd.printString("Volume",20,0); |
AhmedPlaymaker | 5:e4df87957a5b | 73 | float pot; |
AhmedPlaymaker | 5:e4df87957a5b | 74 | pot = pad.read_pot(); |
AhmedPlaymaker | 5:e4df87957a5b | 75 | lcd.drawRect(15,22,54,13,FILL_TRANSPARENT); |
AhmedPlaymaker | 5:e4df87957a5b | 76 | lcd.drawRect(15,22,pot*54,13,FILL_BLACK); |
AhmedPlaymaker | 5:e4df87957a5b | 77 | pad.leds_on(); |
AhmedPlaymaker | 5:e4df87957a5b | 78 | } |
AhmedPlaymaker | 5:e4df87957a5b | 79 | |
AhmedPlaymaker | 5:e4df87957a5b | 80 | int Settings::showCredits(N5110 &lcd, Gamepad &pad) |
AhmedPlaymaker | 5:e4df87957a5b | 81 | { |
AhmedPlaymaker | 5:e4df87957a5b | 82 | lcd.printString("Show Credits?",5,0); |
AhmedPlaymaker | 5:e4df87957a5b | 83 | float pot; |
AhmedPlaymaker | 5:e4df87957a5b | 84 | int show = 1; |
AhmedPlaymaker | 5:e4df87957a5b | 85 | pot = pad.read_pot(); |
AhmedPlaymaker | 5:e4df87957a5b | 86 | |
AhmedPlaymaker | 6:3ffab44ed49c | 87 | if(((0.1<=pot)&&(pot<=0.2))||((0.3<=pot)&&(pot<=0.4))||((0.5<=pot)&&(pot<=0.6))||((0.7<=pot)&&(pot<=0.8))||((0.9<=pot)&&(pot<=1))) { |
AhmedPlaymaker | 5:e4df87957a5b | 88 | lcd.printString("NO",36,3); |
AhmedPlaymaker | 5:e4df87957a5b | 89 | show = 0; |
AhmedPlaymaker | 5:e4df87957a5b | 90 | } |
AhmedPlaymaker | 5:e4df87957a5b | 91 | |
AhmedPlaymaker | 6:3ffab44ed49c | 92 | else { |
AhmedPlaymaker | 5:e4df87957a5b | 93 | lcd.printString("YES",33,3); |
AhmedPlaymaker | 5:e4df87957a5b | 94 | show = 1; |
AhmedPlaymaker | 5:e4df87957a5b | 95 | } |
AhmedPlaymaker | 6:3ffab44ed49c | 96 | |
AhmedPlaymaker | 5:e4df87957a5b | 97 | pad.leds_on(); |
AhmedPlaymaker | 5:e4df87957a5b | 98 | return show; |
AhmedPlaymaker | 5:e4df87957a5b | 99 | } |