![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Owen Cavender 201159294
Diff: main.cpp
- Revision:
- 8:997f90c88246
- Parent:
- 6:bf90044188d0
- Child:
- 9:a69a6a06dddf
--- a/main.cpp Thu May 28 15:08:11 2020 +0000 +++ b/main.cpp Thu May 28 18:50:56 2020 +0000 @@ -20,7 +20,8 @@ #include "Gamepad.h" #include "N5110.h" #include "snake.h" -#include "Apple.h" +#include "GameEngine.h" + @@ -30,6 +31,7 @@ N5110 lcd; Apple apple; Timer timer; +GameEngine engine; //functions void welcome(); @@ -51,15 +53,24 @@ render(); timer.start(); //ROB atm the code works to here //need to draw an initial snake + while (1) { - ; - snake.get_position(pad); + + snake.get_direction(pad); + snake.render_clear_tail(lcd); // =needs to be cleared before _x3, _y3 is updated + snake.move_snake(); + snake.check_collisions(); - snake.check_score(lcd, pad, apple, timer); - snake.get_timer(timer); + snake.apple_collected(lcd, pad, apple, timer); + + engine.get_time(timer); + engine.get_LEDs(pad); + gameover_true(); - snake.render(lcd, apple); + snake.render(lcd); + engine.print_display_time + wait(1.0f/fps); } @@ -82,7 +93,7 @@ void welcome() { - lcd.refresh(); + printf("hello world"); lcd.printString(" SNAKE ",0,1); lcd.printString(" Press Start ",0,4); @@ -94,7 +105,7 @@ pad.leds_off(); wait(0.1); } - + lcd.refresh(); } @@ -119,7 +130,7 @@ lcd.clear(); lcd.refresh(); lcd.printString( " Game Over L ", 0, 2 ); - snake.print_scores(lcd); + engine.print_scores(lcd); if (score <= 7) { lcd.printString(" Loser ", 0,10);