Joe Shotton / Mbed 2 deprecated ELEC2645_Project_ll16j23s

Dependencies:   mbed ll16j23s_test_docs

Committer:
JoeShotton
Date:
Mon May 25 14:45:32 2020 +0000
Revision:
8:bcc3403d7e79
Parent:
7:dd84e0fab346
Child:
9:0571880085cc
Added contrast adjustments for all menu states

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JoeShotton 3:fcd6d70e9694 1 #include "SnakeEngine.h"
JoeShotton 3:fcd6d70e9694 2
JoeShotton 7:dd84e0fab346 3 SnakeEngine::SnakeEngine() {
JoeShotton 7:dd84e0fab346 4 //constructor
JoeShotton 4:ea3fa51c4386 5 score = 0;
JoeShotton 7:dd84e0fab346 6 _menu_select = 1;
JoeShotton 7:dd84e0fab346 7 _map = 1;
JoeShotton 7:dd84e0fab346 8 _game_state = 1;
JoeShotton 8:bcc3403d7e79 9 _pot2 = 0.5;
JoeShotton 3:fcd6d70e9694 10 }
JoeShotton 3:fcd6d70e9694 11
JoeShotton 3:fcd6d70e9694 12 SnakeEngine::~SnakeEngine()
JoeShotton 3:fcd6d70e9694 13 {
JoeShotton 3:fcd6d70e9694 14 //destructor
JoeShotton 3:fcd6d70e9694 15 }
JoeShotton 3:fcd6d70e9694 16
JoeShotton 7:dd84e0fab346 17 void SnakeEngine::game_init(Gamepad &pad, N5110 &lcd, FXOS8700CQ &mag){
JoeShotton 5:06fa7674622a 18 _food.init(mag);
JoeShotton 6:6c9453397f4a 19 _body.init();
JoeShotton 8:bcc3403d7e79 20 _food.rand_pos(pad, lcd);
JoeShotton 7:dd84e0fab346 21 transition_black(lcd);
JoeShotton 7:dd84e0fab346 22 transition_white(lcd);
JoeShotton 7:dd84e0fab346 23 }
JoeShotton 7:dd84e0fab346 24
JoeShotton 4:ea3fa51c4386 25
JoeShotton 7:dd84e0fab346 26 void SnakeEngine::game_run(Gamepad &pad, N5110 &lcd){
JoeShotton 7:dd84e0fab346 27 //input???
JoeShotton 8:bcc3403d7e79 28 map_run(lcd);
JoeShotton 7:dd84e0fab346 29 move_body(pad, lcd);
JoeShotton 8:bcc3403d7e79 30 snake_food_collision(pad, lcd, _body._length);
JoeShotton 8:bcc3403d7e79 31 if (_body.snake_snake_collision(pad) == true) {
JoeShotton 8:bcc3403d7e79 32 //death_init(lcd);
JoeShotton 8:bcc3403d7e79 33 //_game_state = 4;
JoeShotton 8:bcc3403d7e79 34 }
JoeShotton 7:dd84e0fab346 35 //snake-wall collision
JoeShotton 7:dd84e0fab346 36 }
JoeShotton 7:dd84e0fab346 37
JoeShotton 7:dd84e0fab346 38
JoeShotton 7:dd84e0fab346 39 void SnakeEngine::move_body(Gamepad &pad, N5110 &lcd){
JoeShotton 4:ea3fa51c4386 40 _body.snake_movement(pad);
JoeShotton 4:ea3fa51c4386 41 _body.draw_body(lcd);
JoeShotton 4:ea3fa51c4386 42 //printf("Moving!");
JoeShotton 4:ea3fa51c4386 43 _food.do_food(lcd);
JoeShotton 8:bcc3403d7e79 44 snake_food_collision(pad, lcd, _body._length);
JoeShotton 7:dd84e0fab346 45 }
JoeShotton 4:ea3fa51c4386 46
JoeShotton 8:bcc3403d7e79 47 void SnakeEngine::snake_food_collision(Gamepad &pad, N5110 &lcd, int &_length) {
JoeShotton 4:ea3fa51c4386 48 if (_food._x == _body._x_head && _food._y == _body._y_head){
JoeShotton 4:ea3fa51c4386 49 //printf("FOOD!");
JoeShotton 8:bcc3403d7e79 50 while (_food.rand_pos(pad, lcd) == false){
JoeShotton 8:bcc3403d7e79 51 _food.rand_pos(pad, lcd);
JoeShotton 8:bcc3403d7e79 52 printf("Reselected food position\n");
JoeShotton 8:bcc3403d7e79 53 }
JoeShotton 4:ea3fa51c4386 54 pad.led(3,0.9);
JoeShotton 4:ea3fa51c4386 55 _length += 5;
JoeShotton 4:ea3fa51c4386 56 score++;
JoeShotton 4:ea3fa51c4386 57 }
JoeShotton 4:ea3fa51c4386 58 }
JoeShotton 4:ea3fa51c4386 59
JoeShotton 8:bcc3403d7e79 60 void SnakeEngine::map_run(N5110 &lcd) {
JoeShotton 7:dd84e0fab346 61
JoeShotton 7:dd84e0fab346 62 switch(_map) {
JoeShotton 8:bcc3403d7e79 63 case 2:
JoeShotton 8:bcc3403d7e79 64 map2_draw(lcd);
JoeShotton 8:bcc3403d7e79 65 snake_map2_collision();
JoeShotton 8:bcc3403d7e79 66 break;
JoeShotton 8:bcc3403d7e79 67 case 3:
JoeShotton 8:bcc3403d7e79 68 map3_draw(lcd);
JoeShotton 8:bcc3403d7e79 69 snake_map3_collision();
JoeShotton 8:bcc3403d7e79 70 break;
JoeShotton 8:bcc3403d7e79 71 case 4:
JoeShotton 8:bcc3403d7e79 72 map4_draw(lcd);
JoeShotton 8:bcc3403d7e79 73 snake_map4_collision();
JoeShotton 8:bcc3403d7e79 74 break;
JoeShotton 7:dd84e0fab346 75 }
JoeShotton 7:dd84e0fab346 76 }
JoeShotton 7:dd84e0fab346 77
JoeShotton 8:bcc3403d7e79 78 bool SnakeEngine::snake_map2_collision() {
JoeShotton 8:bcc3403d7e79 79 if (_body._x_head == 0 || _body._x_head == 82 || _body._y_head == 0 || _body._y_head == 46){ //if snakehead coords exceed the ring coords
JoeShotton 8:bcc3403d7e79 80 return true;
JoeShotton 8:bcc3403d7e79 81 }
JoeShotton 8:bcc3403d7e79 82 }
JoeShotton 8:bcc3403d7e79 83
JoeShotton 8:bcc3403d7e79 84 bool SnakeEngine::snake_map3_collision() {
JoeShotton 8:bcc3403d7e79 85 /*
JoeShotton 8:bcc3403d7e79 86 if (_body._x_head == 0 || _body._x_head == 82 || _body._y_head == 0 || _body._y_head == 46){
JoeShotton 8:bcc3403d7e79 87 return true;
JoeShotton 8:bcc3403d7e79 88 }
JoeShotton 8:bcc3403d7e79 89 */
JoeShotton 8:bcc3403d7e79 90 }
JoeShotton 8:bcc3403d7e79 91
JoeShotton 8:bcc3403d7e79 92 bool SnakeEngine::snake_map4_collision() {
JoeShotton 8:bcc3403d7e79 93 /*
JoeShotton 8:bcc3403d7e79 94 for(int i = 0; i < 48; i++){
JoeShotton 8:bcc3403d7e79 95 if(_body._x_head == MAP 4 COORDS && _body._y_head == MAP 4 COORDS) {
JoeShotton 8:bcc3403d7e79 96 return true;
JoeShotton 8:bcc3403d7e79 97 }
JoeShotton 8:bcc3403d7e79 98 */
JoeShotton 8:bcc3403d7e79 99 }
JoeShotton 8:bcc3403d7e79 100
JoeShotton 8:bcc3403d7e79 101 void SnakeEngine::map2_draw(N5110 &lcd){
JoeShotton 7:dd84e0fab346 102 lcd.drawRect(0, 0, 84, 48,FILL_TRANSPARENT);
JoeShotton 7:dd84e0fab346 103 lcd.drawRect(1, 1, 82, 46,FILL_TRANSPARENT);
JoeShotton 7:dd84e0fab346 104 }
JoeShotton 7:dd84e0fab346 105
JoeShotton 8:bcc3403d7e79 106 void SnakeEngine::map3_draw(N5110 &lcd){
JoeShotton 8:bcc3403d7e79 107 lcd.drawRect(40, 0, 4, 16,FILL_BLACK); //N wall
JoeShotton 8:bcc3403d7e79 108 lcd.drawRect(68, 22, 16, 4,FILL_BLACK);//E wall
JoeShotton 8:bcc3403d7e79 109 lcd.drawRect(40, 32, 4, 16,FILL_BLACK);//S wall
JoeShotton 8:bcc3403d7e79 110 lcd.drawRect(0, 22, 16, 4,FILL_BLACK); //W wall
JoeShotton 7:dd84e0fab346 111 }
JoeShotton 7:dd84e0fab346 112
JoeShotton 8:bcc3403d7e79 113 void SnakeEngine::map4_draw(N5110 &lcd){
JoeShotton 7:dd84e0fab346 114 lcd.drawRect(12, 8, 4, 4,FILL_BLACK); //NW square
JoeShotton 7:dd84e0fab346 115 lcd.drawRect(12, 36, 4, 4,FILL_BLACK);//SW square
JoeShotton 7:dd84e0fab346 116 lcd.drawRect(68, 8, 4, 4,FILL_BLACK); //NE square
JoeShotton 7:dd84e0fab346 117 lcd.drawRect(68, 36, 4, 4,FILL_BLACK);//SE square
JoeShotton 7:dd84e0fab346 118
JoeShotton 7:dd84e0fab346 119 lcd.drawRect(40, 6, 4, 8,FILL_BLACK); //N spot, vertical
JoeShotton 7:dd84e0fab346 120 lcd.drawRect(38, 8, 8, 4,FILL_BLACK); //N spot, horizontal
JoeShotton 7:dd84e0fab346 121
JoeShotton 7:dd84e0fab346 122 lcd.drawRect(26, 20, 4, 8,FILL_BLACK);//E spot, vertical
JoeShotton 7:dd84e0fab346 123 lcd.drawRect(24, 22, 8, 4,FILL_BLACK);//E spot, horizontal
JoeShotton 7:dd84e0fab346 124
JoeShotton 7:dd84e0fab346 125 lcd.drawRect(40, 34, 4, 8,FILL_BLACK);//S spot, vertical
JoeShotton 7:dd84e0fab346 126 lcd.drawRect(38, 36, 8, 4,FILL_BLACK);//S spot, horizontal
JoeShotton 7:dd84e0fab346 127
JoeShotton 7:dd84e0fab346 128 lcd.drawRect(54, 20, 4, 8,FILL_BLACK);//W spot, vertical
JoeShotton 7:dd84e0fab346 129 lcd.drawRect(52, 22, 8, 4,FILL_BLACK);//W spot, horizontal
JoeShotton 7:dd84e0fab346 130 }
JoeShotton 7:dd84e0fab346 131
JoeShotton 7:dd84e0fab346 132
JoeShotton 6:6c9453397f4a 133 void SnakeEngine::transition_black(N5110 &lcd) {
JoeShotton 6:6c9453397f4a 134 //lcd.clear();
JoeShotton 7:dd84e0fab346 135 for (int j = 0; j < 21; j += 4) { //j iterator controls the size and location of current loop
JoeShotton 7:dd84e0fab346 136 //printf("j: %d\n", j);
JoeShotton 7:dd84e0fab346 137 for (int i = 1; i < 84 - (2*j); i += 2) { //i iterator controls length of rectangles
JoeShotton 7:dd84e0fab346 138 lcd.drawRect(j, j, i + 1, 4, FILL_BLACK); //top horizontal rectangle
JoeShotton 7:dd84e0fab346 139 lcd.drawRect(83 - j - i, 44 - j, i + 1, 4, FILL_BLACK); //bottom horizontal rectangle
JoeShotton 6:6c9453397f4a 140 wait_ms(5);
JoeShotton 7:dd84e0fab346 141 lcd.refresh(); //refreshes screen without clearing it to maintain previous loops
JoeShotton 6:6c9453397f4a 142 }
JoeShotton 7:dd84e0fab346 143 for (int i = 1; i < 43 - (2*j); i += 2) { //i iterator controls length of rectangles
JoeShotton 7:dd84e0fab346 144 lcd.drawRect(80 - j, 4 + j, 4, i,FILL_BLACK); //right vertical rectangle
JoeShotton 7:dd84e0fab346 145 lcd.drawRect(j, 44 - i - j, 4, i,FILL_BLACK); //left vertical rectangle
JoeShotton 6:6c9453397f4a 146 wait_ms(5);
JoeShotton 7:dd84e0fab346 147 lcd.refresh(); //refreshes screen without clearing it to maintain previous loops
JoeShotton 6:6c9453397f4a 148 }
JoeShotton 6:6c9453397f4a 149 }
JoeShotton 7:dd84e0fab346 150 //wait_ms(500);
JoeShotton 6:6c9453397f4a 151 }
JoeShotton 6:6c9453397f4a 152
JoeShotton 6:6c9453397f4a 153 void SnakeEngine::transition_white(N5110 &lcd) {
JoeShotton 6:6c9453397f4a 154 //lcd.clear();
JoeShotton 6:6c9453397f4a 155 for (int j = 0; j < 21; j += 4) {
JoeShotton 7:dd84e0fab346 156 //printf("j: %d\n", j);
JoeShotton 6:6c9453397f4a 157 for (int i = 1; i < 84 - (2*j); i += 2) {
JoeShotton 6:6c9453397f4a 158 lcd.drawRect(j, j, i + 1, 4, FILL_WHITE);
JoeShotton 6:6c9453397f4a 159 lcd.drawRect(83 - j - i, 44 - j, i + 1, 4, FILL_WHITE);
JoeShotton 6:6c9453397f4a 160 wait_ms(5);
JoeShotton 6:6c9453397f4a 161 lcd.refresh();
JoeShotton 6:6c9453397f4a 162 }
JoeShotton 6:6c9453397f4a 163 for (int i = 1; i < 43 - (2*j); i += 2) {
JoeShotton 6:6c9453397f4a 164 lcd.drawRect(80 - j, 4 + j, 4, i,FILL_WHITE);
JoeShotton 6:6c9453397f4a 165 lcd.drawRect(j, 44 - i - j, 4, i,FILL_WHITE);
JoeShotton 6:6c9453397f4a 166 wait_ms(5);
JoeShotton 6:6c9453397f4a 167 lcd.refresh();
JoeShotton 6:6c9453397f4a 168 }
JoeShotton 6:6c9453397f4a 169 }
JoeShotton 6:6c9453397f4a 170 //wait_ms(500);
JoeShotton 6:6c9453397f4a 171 }
JoeShotton 7:dd84e0fab346 172
JoeShotton 7:dd84e0fab346 173 void SnakeEngine::menu1_init(N5110 &lcd){
JoeShotton 7:dd84e0fab346 174 transition_black(lcd);
JoeShotton 7:dd84e0fab346 175 transition_white(lcd);
JoeShotton 7:dd84e0fab346 176 lcd.clear();
JoeShotton 7:dd84e0fab346 177 lcd.refresh();
JoeShotton 7:dd84e0fab346 178 //printf("Menu 2\n");
JoeShotton 7:dd84e0fab346 179 lcd.printString(" SNAKE",3,0);
JoeShotton 7:dd84e0fab346 180 lcd.printString("Play",30,2);
JoeShotton 7:dd84e0fab346 181 lcd.drawCircle(24,19,3,FILL_TRANSPARENT);
JoeShotton 7:dd84e0fab346 182 lcd.printString("Maps",30,3);
JoeShotton 7:dd84e0fab346 183 lcd.drawCircle(24,27,3,FILL_TRANSPARENT);
JoeShotton 7:dd84e0fab346 184 lcd.refresh();
JoeShotton 7:dd84e0fab346 185 }
JoeShotton 7:dd84e0fab346 186
JoeShotton 7:dd84e0fab346 187 void SnakeEngine::menu1_select(N5110 &lcd, Gamepad &pad){
JoeShotton 7:dd84e0fab346 188 //printf("Menu 1\n");
JoeShotton 7:dd84e0fab346 189 if (pad.X_pressed() == true){ //detect if 'up' selection
JoeShotton 7:dd84e0fab346 190 _menu_select--;
JoeShotton 7:dd84e0fab346 191 } else if (pad.B_pressed() == true){ //detect if 'down' selection
JoeShotton 7:dd84e0fab346 192 _menu_select++;
JoeShotton 7:dd84e0fab346 193 }
JoeShotton 7:dd84e0fab346 194 //printf("Option: %d\n", _menu_select);
JoeShotton 7:dd84e0fab346 195 if (pad.A_pressed() == true && _menu_select == 1){ //if option 1 selected and 'A' pressed
JoeShotton 7:dd84e0fab346 196 //game_init(); //Initialise game
JoeShotton 7:dd84e0fab346 197 _game_state = 3; //switch state
JoeShotton 7:dd84e0fab346 198 } else if (pad.A_pressed() == true && _menu_select == 2){ //if option 2 selected and 'A' pressed
JoeShotton 7:dd84e0fab346 199 menu2_init(lcd); //Initialise map menu
JoeShotton 7:dd84e0fab346 200 _game_state = 2; //switch state
JoeShotton 7:dd84e0fab346 201 }
JoeShotton 7:dd84e0fab346 202 if (_menu_select > 2) { //bottom - top wrap around
JoeShotton 7:dd84e0fab346 203 _menu_select = 1;
JoeShotton 7:dd84e0fab346 204 } else if (_menu_select < 1) { ////top - bottom wrap around
JoeShotton 7:dd84e0fab346 205 _menu_select = 2;
JoeShotton 7:dd84e0fab346 206 }
JoeShotton 7:dd84e0fab346 207 select_circles(lcd, _menu_select); //draw black circle in selected option
JoeShotton 7:dd84e0fab346 208 }
JoeShotton 7:dd84e0fab346 209
JoeShotton 7:dd84e0fab346 210 void SnakeEngine::menu2_init(N5110 &lcd){
JoeShotton 7:dd84e0fab346 211 //transition_black(lcd);
JoeShotton 7:dd84e0fab346 212 //transition_white(lcd);
JoeShotton 7:dd84e0fab346 213 //printf("Menu 1\n");
JoeShotton 7:dd84e0fab346 214 lcd.clear();
JoeShotton 7:dd84e0fab346 215 lcd.printString(" MAPS",0,0);
JoeShotton 7:dd84e0fab346 216 lcd.printString("Empty",30,2);
JoeShotton 7:dd84e0fab346 217 lcd.drawCircle(24,19,3,FILL_TRANSPARENT);
JoeShotton 7:dd84e0fab346 218 lcd.printString("Ring",30,3);
JoeShotton 7:dd84e0fab346 219 lcd.drawCircle(24,27,3,FILL_TRANSPARENT);
JoeShotton 7:dd84e0fab346 220 lcd.printString("Cross",30,4);
JoeShotton 7:dd84e0fab346 221 lcd.drawCircle(24,35,3,FILL_TRANSPARENT);
JoeShotton 7:dd84e0fab346 222 lcd.printString("Spots",30,5);
JoeShotton 7:dd84e0fab346 223 lcd.drawCircle(24,43,3,FILL_TRANSPARENT);
JoeShotton 7:dd84e0fab346 224 lcd.refresh();
JoeShotton 7:dd84e0fab346 225 }
JoeShotton 7:dd84e0fab346 226
JoeShotton 7:dd84e0fab346 227 void SnakeEngine::menu2_select(N5110 &lcd, Gamepad &pad){
JoeShotton 7:dd84e0fab346 228
JoeShotton 7:dd84e0fab346 229 //printf("Menu 2\n");
JoeShotton 7:dd84e0fab346 230 if (pad.X_pressed() == true){
JoeShotton 7:dd84e0fab346 231 _map--;
JoeShotton 7:dd84e0fab346 232 } else if (pad.B_pressed() == true){
JoeShotton 7:dd84e0fab346 233 _map++;
JoeShotton 7:dd84e0fab346 234 } else if (pad.Y_pressed() == true){
JoeShotton 7:dd84e0fab346 235 preview(lcd, _map);
JoeShotton 7:dd84e0fab346 236 } else if (pad.A_pressed() == true){
JoeShotton 7:dd84e0fab346 237 //game_init();
JoeShotton 7:dd84e0fab346 238 _game_state = 3;
JoeShotton 7:dd84e0fab346 239 }
JoeShotton 7:dd84e0fab346 240
JoeShotton 7:dd84e0fab346 241 //printf("Map: %d\n", _map);
JoeShotton 7:dd84e0fab346 242 if (_map > 4) {
JoeShotton 7:dd84e0fab346 243 _map = 1;
JoeShotton 7:dd84e0fab346 244 } else if (_map < 1) {
JoeShotton 7:dd84e0fab346 245 _map = 4;
JoeShotton 7:dd84e0fab346 246 }
JoeShotton 7:dd84e0fab346 247 select_circles(lcd, _map);
JoeShotton 7:dd84e0fab346 248 }
JoeShotton 7:dd84e0fab346 249
JoeShotton 7:dd84e0fab346 250
JoeShotton 7:dd84e0fab346 251 void SnakeEngine::death_init(N5110 &lcd){
JoeShotton 7:dd84e0fab346 252 wait_ms(500);
JoeShotton 7:dd84e0fab346 253 transition_black(lcd);
JoeShotton 7:dd84e0fab346 254 transition_white(lcd);
JoeShotton 7:dd84e0fab346 255 //printf("Game over\n");
JoeShotton 7:dd84e0fab346 256 lcd.printString(" GAME OVER ",0,0);
JoeShotton 7:dd84e0fab346 257 lcd.printString(" Score =",3,1);
JoeShotton 7:dd84e0fab346 258 char buffer[14];
JoeShotton 7:dd84e0fab346 259 if (score < 10){
JoeShotton 7:dd84e0fab346 260 sprintf(buffer," 0%2d",score);
JoeShotton 7:dd84e0fab346 261 } else {
JoeShotton 7:dd84e0fab346 262 sprintf(buffer," %2d",score);
JoeShotton 7:dd84e0fab346 263 }
JoeShotton 7:dd84e0fab346 264 lcd.printString(buffer,0,2);
JoeShotton 7:dd84e0fab346 265 lcd.printString("Again!",24,4);
JoeShotton 7:dd84e0fab346 266 lcd.drawCircle(24,35,3,FILL_TRANSPARENT);
JoeShotton 7:dd84e0fab346 267 lcd.printString("Menu",24,5);
JoeShotton 7:dd84e0fab346 268 lcd.drawCircle(24,44,3,FILL_TRANSPARENT);
JoeShotton 7:dd84e0fab346 269 lcd.refresh();
JoeShotton 7:dd84e0fab346 270 }
JoeShotton 7:dd84e0fab346 271
JoeShotton 7:dd84e0fab346 272 void SnakeEngine::death_select(N5110 &lcd, Gamepad &pad){
JoeShotton 7:dd84e0fab346 273
JoeShotton 7:dd84e0fab346 274 }
JoeShotton 7:dd84e0fab346 275
JoeShotton 7:dd84e0fab346 276 void SnakeEngine::select_circles(N5110 &lcd, int line) {
JoeShotton 7:dd84e0fab346 277 for(int i = 19; i < 52; i +=8) {
JoeShotton 7:dd84e0fab346 278 lcd.drawCircle(24,i,2,FILL_WHITE);
JoeShotton 7:dd84e0fab346 279 }
JoeShotton 7:dd84e0fab346 280 lcd.drawCircle(24,11+line*8,2,FILL_BLACK);
JoeShotton 7:dd84e0fab346 281 lcd.refresh();
JoeShotton 7:dd84e0fab346 282 wait_ms(200);
JoeShotton 7:dd84e0fab346 283 //snake_select1.render(lcd, 0, 8);
JoeShotton 7:dd84e0fab346 284 //wait_ms(200);
JoeShotton 7:dd84e0fab346 285 //snake_select2.render(lcd, 0, 8);
JoeShotton 7:dd84e0fab346 286 //wait_ms(200);
JoeShotton 7:dd84e0fab346 287 //snake_select3.render(lcd, 0, 8);
JoeShotton 7:dd84e0fab346 288 //wait_ms(200);
JoeShotton 7:dd84e0fab346 289 }
JoeShotton 7:dd84e0fab346 290
JoeShotton 7:dd84e0fab346 291 void SnakeEngine::preview(N5110 &lcd, int _map){
JoeShotton 7:dd84e0fab346 292 lcd.clear();
JoeShotton 7:dd84e0fab346 293 switch(_map) {
JoeShotton 7:dd84e0fab346 294 case 1:
JoeShotton 7:dd84e0fab346 295 lcd.clear();
JoeShotton 8:bcc3403d7e79 296 lcd.printString("(Empty)",21,2);
JoeShotton 7:dd84e0fab346 297 break;
JoeShotton 7:dd84e0fab346 298 case 2:
JoeShotton 8:bcc3403d7e79 299 map2_draw(lcd);
JoeShotton 8:bcc3403d7e79 300 //lcd.printString("Ring",30,2);
JoeShotton 7:dd84e0fab346 301 break;
JoeShotton 7:dd84e0fab346 302 case 3:
JoeShotton 8:bcc3403d7e79 303 map3_draw(lcd);
JoeShotton 8:bcc3403d7e79 304 //lcd.printString("Cross",27,2);
JoeShotton 7:dd84e0fab346 305 break;
JoeShotton 7:dd84e0fab346 306 case 4:
JoeShotton 8:bcc3403d7e79 307 map4_draw(lcd);
JoeShotton 8:bcc3403d7e79 308 //lcd.printString("Spots",27,2);
JoeShotton 7:dd84e0fab346 309 break;
JoeShotton 7:dd84e0fab346 310 }
JoeShotton 7:dd84e0fab346 311 lcd.refresh();
JoeShotton 7:dd84e0fab346 312 wait_ms(1000);
JoeShotton 7:dd84e0fab346 313 lcd.clear();
JoeShotton 7:dd84e0fab346 314 menu2_init(lcd);
JoeShotton 8:bcc3403d7e79 315 }
JoeShotton 8:bcc3403d7e79 316
JoeShotton 8:bcc3403d7e79 317 void SnakeEngine::contrast(Gamepad &pad, N5110 &lcd){
JoeShotton 8:bcc3403d7e79 318 _pot2 = pad.read_pot2();
JoeShotton 8:bcc3403d7e79 319 lcd.setContrast(0.25 + _pot2 * 0.5);
JoeShotton 8:bcc3403d7e79 320 //printf("Contrast: %f\n", 0.25 + _pot2 * 0.5);
JoeShotton 7:dd84e0fab346 321 }