Ahmed Adamjee
/
SnakeVSBlock
Snake vs Block Game to be run upon K64F.
Diff: main.cpp
- Revision:
- 49:441c32f6603e
- Parent:
- 47:b448ffd073e7
- Child:
- 50:3cf9a94a264e
--- a/main.cpp Fri Apr 26 12:46:42 2019 +0000 +++ b/main.cpp Fri Apr 26 17:16:22 2019 +0000 @@ -28,6 +28,7 @@ Gamepad pad; FXOS8700CQ device(I2C_SDA,I2C_SCL); StartScreen _start; +Stats stats; SnakevsBlock game; AnalogIn noisy(PTB0); //This creates a random noise which I can use to seed the random numbers. // Connections to SD card holder on K64F (SPI interface) @@ -49,9 +50,10 @@ init(); _start.screen_saver(lcd, pad); _start.instruct(lcd, pad); - _start.info(lcd, pad); while(1) { //This loop is created for Play/Continue configuration - _start.main_menu(lcd, pad, sd); + _start.read_stats(sd); //this is to save the current highest level in the stats class that can be used in menu. + _start.main_menu(lcd, pad); + _start.credits(lcd); // this is after the menu to allow us to hide credits if we want to play the game fast. fps = _start.fps; g_mode = _start.g_mode; // start the game @@ -63,7 +65,7 @@ while (1) { game.read_input(pad, device, g_mode); - int back = game.update(pad); + int back = game.update(lcd, pad, sd); refresh_game(); wait(1.0f/fps); @@ -83,13 +85,14 @@ pad.init(); pad.tone(1000.0,0.1); game.init(); + _start.init(); srand(100000*noisy.read_u16()); } void refresh_game() { lcd.clear(); - game.draw(lcd, pad, sd); + game.draw(lcd, pad); game.get_pos(); lcd.refresh(); } \ No newline at end of file