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:
- 8:30ad5229cc0b
- Parent:
- 7:bd4b84e2320e
- Child:
- 10:946a3835a7c7
--- a/Snake/Snake.cpp Wed May 02 13:37:36 2018 +0000
+++ b/Snake/Snake.cpp Thu May 03 00:53:06 2018 +0000
@@ -19,7 +19,8 @@
}
dir_snake = 1;
_array = 100;
- _point = 6;
+ _point = 0;
+ _snakesize = 6;
}
void snake::update(Direction d,float mag){
@@ -41,6 +42,60 @@
{ dir_snake = 4 ;}
}
+
+
+void snake::draw(N5110 &lcd)
+{
+ for(int i=0; i<_snakesize; i++) {
+ lcd.setPixel(_xnewpos[i],_ynewpos[i]);
+ }
+}
+
+Vector2D snake::get_pos()
+{
+ Vector2D p = {_xnewpos[0],_ynewpos[0]};
+ return p;
+}
+
+void snake::set_pos(Vector2D p)
+{
+ _xnewpos[0] = p.x;
+ _ynewpos[0] = p.y;
+
+}
+
+
+void snake::point()
+{
+ _point++;
+
+}
+
+
+int snake::get_point()
+{
+ return _point ;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+