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: SnakeTail/SnakeTail.cpp
- Revision:
- 5:256e5e0b6cd7
- Child:
- 6:964cc4896627
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/SnakeTail/SnakeTail.cpp Thu May 14 12:06:26 2020 +0000
@@ -0,0 +1,43 @@
+#include "SnakeTail.h"
+
+SnakeTail::SnakeTail()
+{
+
+}
+
+SnakeTail::~SnakeTail()
+{
+
+}
+
+
+void SnakeTail::set_length(int length)
+{
+ _length = length;
+}
+
+void SnakeTail::draw_tail(N5110 &lcd, Vector2D headPos)
+{
+ tailX[0] = headPos.x;
+ tailY[0] = headPos.y;
+ int prevX = tailX[0];
+ int prevY = tailY[0];
+ int prev2X = prevX;
+ int prev2Y = prevY;
+
+
+ for (int i = 1; i<_length; i++) {
+ prev2X = prevX;
+ prev2Y = prevY;
+ prevX = tailX[i];
+ prevY = tailY[i];
+ tailX[i] = headPos.x;
+ tailY[i] = headPos.y;
+ lcd.drawRect(prev2X, prev2Y, 2, 2, FILL_BLACK);
+ };
+}
+
+
+
+
+
\ No newline at end of file