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: Snake/Snake.cpp
- Revision:
- 7:bd4b84e2320e
- Parent:
- 6:53c1fda99a3a
- Child:
- 8:30ad5229cc0b
--- a/Snake/Snake.cpp Tue May 01 00:58:15 2018 +0000
+++ b/Snake/Snake.cpp Wed May 02 13:37:36 2018 +0000
@@ -17,12 +17,31 @@
_xnewpos[i] = 15 ;
_ynewpos[i] = 23;
}
- dir = 0;
+ dir_snake = 1;
_array = 100;
_point = 6;
}
void snake::update(Direction d,float mag){
+ if (dir_snake == 1){
+ s ;}
+ else if (dir_snake == 2){
+ n;}
+ else if (dir_snake == 3){
+ e;}
+ else if (dir_snake == 4){
+ w;}
+ if ((d == S))
+ { dir_snake = 1 ;}
+ if ((d == N))
+ { dir_snake = 2 ;}
+ if ((d == E))
+ { dir_snake = 3 ;}
+ if ((d == W))
+ { dir_snake = 4 ;}
+
+}
+