Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 5:256e5e0b6cd7
- Parent:
- 4:c5addc5475d3
- Child:
- 6:964cc4896627
--- a/main.cpp Fri May 08 08:40:29 2020 +0000 +++ b/main.cpp Thu May 14 12:06:26 2020 +0000 @@ -14,15 +14,16 @@ #include "mbed.h" #include "Gamepad.h" #include "N5110.h" -#include "Snake.h" - +#include "SnakeHead.h" +#include "SnakeTail.h" // objects Gamepad pad; N5110 lcd; BusIn input(PTC5, PTC9, PTC7); -Snake snake; +SnakeHead head; +SnakeTail tail; void welcome(); @@ -61,15 +62,22 @@ switch(state) { case 3: - snake.init(1,3); + head.init(1,3); + + while(1) { lcd.clear(); - snake.draw(lcd); + head.draw(lcd); Direction _d = pad.get_direction(); //printf("Stick direction: %s", d); - snake.change_direction(_d); - snake.update(); + head.change_direction(_d); + head.update(); + Vector2D headPos = head.get_pos(); + //printf("pos x = %i\n", headPos.x); + tail.set_length(15); + tail.draw_tail(lcd, headPos); + lcd.refresh(); wait(0.5); }