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
Revision 14:9e2ce28b4e63, committed 2018-05-06
- Comitter:
- weiway
- Date:
- Sun May 06 12:58:00 2018 +0000
- Parent:
- 13:4026781772cb
- Child:
- 15:47ea86f1ed70
- Commit message:
- the fruit is not on the creen
Changed in this revision
| snake/snake.cpp | Show annotated file Show diff for this revision Revisions of this file |
| snake/snake.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/snake/snake.cpp Sun May 06 12:44:41 2018 +0000
+++ b/snake/snake.cpp Sun May 06 12:58:00 2018 +0000
@@ -11,7 +11,7 @@
}
void snake::init(){
- for (int i = 0; i <_snakesize ; i++) {
+ for (int i = 0; i <_point ; i++) {
_xoldpos[i] = 15;
_yoldpos[i] = 23;
_xnewpos[i] = 15 ;
@@ -19,8 +19,8 @@
}
dir_snake = 3;
_array = 100;
- _point = 0;
- _snakesize = 6;
+ _point = 6;
+
}
void snake::update(Direction d,float mag){
@@ -32,13 +32,13 @@
e();}
else if (dir_snake == 4){
w();}
- if ((d == S))
+ if ((d == S) )
{ dir_snake = 1 ;}
- if ((d == N))
+ if ((d == N) )
{ dir_snake = 2 ;}
- if ((d == E))
+ if ((d == E) )
{ dir_snake = 3 ;}
- if ((d == W))
+ if ((d == W) )
{ dir_snake = 4 ;}
}
@@ -46,7 +46,7 @@
void snake::draw(N5110 &lcd)
{
- for(int i=0; i<_snakesize; i++) {
+ for(int i=0; i<_point; i++) {
lcd.setPixel(_xnewpos[i],_ynewpos[i]);
}
}
@@ -74,7 +74,7 @@
int snake::get_point()
{
- return _point ;
+ return _point -6 ;
}
--- a/snake/snake.h Sun May 06 12:44:41 2018 +0000
+++ b/snake/snake.h Sun May 06 12:58:00 2018 +0000
@@ -24,7 +24,6 @@
private:
- int _snakesize;
int _array;
int _point;
int dir_snake;