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 ll16j23s_test_docs
Diff: Food/Food.cpp
- Revision:
- 3:fcd6d70e9694
- Child:
- 4:ea3fa51c4386
diff -r 86b67b492cbc -r fcd6d70e9694 Food/Food.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Food/Food.cpp Wed May 20 21:25:40 2020 +0000
@@ -0,0 +1,36 @@
+#include "Food.h"
+
+Food::Food()
+{
+//constructor
+}
+
+Food::~Food()
+{
+//deconstructor
+}
+
+void Food::init()
+{
+ _x = 84; // starts off-screen
+ _y = 0;
+ //srand (x); //CHANGE THIS TO ACCELERAOMETRE VALUE
+}
+
+
+Vector2D Food::rand_pos(int cell_size) {
+
+ int _x = cell_size * (rand() % 42); //selects random x cell
+ printf("Food x: %d\n", _x);
+ int _y = cell_size * (rand() % 24); //selects random y call
+ printf("Food y: %d\n", _y);
+ Vector2D pos = {_x,_y};
+ return pos;
+}
+
+
+void Food::draw(N5110 &lcd, int frame)
+{
+ // draw food, with alternate locations depending on frame.
+ lcd.drawLine(_x + frame, _y, _x + 1 - frame,_y + 1,1);
+}