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 17:7c8cf5f7878c, committed 2018-05-08
- Comitter:
- weiway
- Date:
- Tue May 08 11:38:55 2018 +0000
- Parent:
- 16:a790f3f622f8
- Child:
- 18:e58a1f8e72ad
- Commit message:
- collision
Changed in this revision
| snake_engine/snake_engine.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/snake_engine/snake_engine.cpp Tue May 08 11:31:47 2018 +0000
+++ b/snake_engine/snake_engine.cpp Tue May 08 11:38:55 2018 +0000
@@ -30,6 +30,7 @@
void snake_engine::update(Gamepad &pad, N5110 &lcd)
{
s.update(_d,_mag);
+ collision(pad, lcd);
if(getfruit(pad)) {
@@ -73,3 +74,27 @@
lcd.printString(buffer,WIDTH/2 - 40,0);
}
+
+
+
+void snake_engine::collision(Gamepad &pad,N5110 &lcd)
+{
+ Vector2D _s_poss = s.get_pos();
+ if (((_s_poss.x >= WIDTH -2) || (_s_poss.x <= 1)) ||((_s_poss.y >= HEIGHT -1) || (_s_poss.y <= 8)) ) {
+ lcd.clear();
+ }
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+