testing documentation
Dependencies: mbed ll16j23s_test_docs
Diff: main.cpp
- Revision:
- 7:dd84e0fab346
- Parent:
- 6:6c9453397f4a
- Child:
- 8:bcc3403d7e79
diff -r 6c9453397f4a -r dd84e0fab346 main.cpp --- a/main.cpp Sat May 23 20:01:00 2020 +0000 +++ b/main.cpp Sun May 24 22:18:55 2020 +0000 @@ -15,7 +15,9 @@ #include "Gamepad.h" #include "N5110.h" #include "FXOS8700CQ.h" +#include "Bitmap.h" #include "SnakeEngine.h" +#include "Map.h" #include <vector> #include <cstdlib> @@ -32,81 +34,38 @@ lcd.init(); pad.init(); - snake.init(mag); - lcd.setContrast(0.4); + snake.game_init(pad, lcd, mag); - snake.transition_black(lcd); - snake.transition_white(lcd); + snake._game_state = 2; + snake.menu2_init(lcd); + + //snake.transition_black(lcd); + //snake.transition_white(lcd); float speed = 0.5; int fps = 25; int frame_t = 1000/fps; - bool death = false; - //int length = 10; //intial snake size - //int size_inc = 5; //how much longer the snake gets due to food - + while(snake._game_state == 1){ + snake.menu1_select(lcd, pad); + } - //int d = 0; //direction starts in centre - //int state = 0; //first state is centre of joystick - -/* - Dir fsm[5] = { - {0, 0, 0, {0,1,2,3,4}}, // Centred - {1, 0, -1, {1,1,2,1,4}}, // North, will not go to centre or south - {2, 1, 0, {2,1,2,3,2}}, // East, will not go to centre or west - {3, 0, 1, {3,3,2,3,4}}, // South, will not go to centre or north - {4, -1, 0, {4,1,4,3,4}} // West, will not go to centre or east - }; -*/ - while(death == false){ - - //printf("Running!"); - - speed = pad.read_pot2(); - + while(snake._game_state == 2){ + snake.menu2_select(lcd, pad); + } + + while(snake._game_state == 3){ lcd.clear(); - snake.move_body(pad, lcd, death); + snake.game_run(pad, lcd); lcd.refresh(); wait_ms(500/(5+snake.score)); - } -} - -/* if ((lcd.getPixel(x, y) == 1 && ((state == 1) || (state == 4))) || (lcd.getPixel(x+1, y+1) == 1 && ((state == 2) || (state == 3)))) { - // checks infront of head to see if pixel is set - // due to the size of the head, there is an offset for the check for North and Eastward directions - death = true; - pad.led(1,0.9); - } else { - death = false; - pad.led(1,0.0); - } -*/ - - /* - if(pad.B_pressed() == true && length > size_inc) { - length -= size_inc; - printf("Lenght: %d\n", length); - } -*/ - -/* - body_x.insert(body_x.begin(), x_head); //sets first array element to head coordinates - body_y.insert(body_y.begin(), y_head); - - body_x.erase(body_x.begin()+length); - body_y.erase(body_y.begin()+length); -*/ -/* - if(pad.A_pressed() == true) { - length += size_inc; - //printf("Length: %d\n", length); - body = new int*[length]; - for(int i = length + 1; i < length + size_inc + 1; i++) { - body[i] = new int[2]; - body[i][0] = X_MAX + 1; //snake body starts outside the screen - body[i][1] = 0; - } -*/ + } + + while(snake._game_state == 4){ + //snake.death; + } + +} +