![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Owen Cavender 201159294
Diff: main.cpp
- Revision:
- 2:44e4a6ecdbef
- Parent:
- 1:897160a1a3ae
- Child:
- 4:748e3ff14e72
--- a/main.cpp Tue May 26 12:17:59 2020 +0000 +++ b/main.cpp Tue May 26 18:35:44 2020 +0000 @@ -34,7 +34,7 @@ void init(); void update_game_state(); -int main() //FUNCTION 0 +int main() { int fps = 6; // frames per second @@ -43,12 +43,12 @@ welcome(); wait(1.0f/fps); // and wait for one frame period render(); - - // game loop - read input, update the game state and render the display + //ROB atm the code works to here + //need to draw an initial snake while (1) { snake.set_direction(pad); update_game_state(); - wait(1.0f/fps); //need to make wait function - relate it to clock + wait(1.0f/fps); } } @@ -61,14 +61,14 @@ snake.init(); //need to initialise snake class pad.init(); lcd.init(); - engine.init(48, 24, 48, 30); // need to choose initial values A$AP shx shy apx apy + engine.init(48, 24, 48, 30, 48, 47); // need to choose initial values A$AP shx shy apx apy Oshx, Oshy } void update_game_state() //FUNCTION 2 { snake.set_direction(pad); - snake.move_and_draw_snake(lcd); + snake.move_and_draw_snake(pad, lcd); snake.gameover_true(lcd); snake.check_if_scored(lcd, pad); @@ -93,14 +93,17 @@ } -//void render(N5110 &lcd) -//{ void render() { // clear screen, re-draw and refresh lcd.clear(); lcd.drawRect(0, 0, 84, 42, FILL_TRANSPARENT); - lcd.refresh(); + Vector2D originalhead = engine.get_Snakehead(); //draw constant rectangle around frame of lcd indicating walls + Vector2D originalbody = engine.get_oldSnakehead(); + + lcd.setPixel(originalhead.x, originalhead.y,1); + lcd.setPixel(originalbody.x, originalbody.y,1); + }