Joe Shotton / Mbed 2 deprecated ELEC2645_Project_ll16j23s

Dependencies:   mbed ll16j23s_test_docs

Revision:
3:fcd6d70e9694
Child:
4:ea3fa51c4386
--- /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);
+}