Faizan and Pages fun little game

Dependencies:   4DGL-uLCD-SE mbed SDFileSystem wave_player

Revision:
1:9eeeb0d8f036
Parent:
0:de9ffb858be9
Child:
2:4c5f409d6bb8
--- a/stack.cpp	Fri Oct 28 17:33:29 2016 +0000
+++ b/stack.cpp	Sat Oct 29 19:35:46 2016 +0000
@@ -2,6 +2,7 @@
 #include "uLCD_4DGL.h"
 #include "stack.h"
 #include "food.h"
+#include <algorithm>
 
 #define BREAD 1
 #define LETTUCE 2
@@ -11,10 +12,20 @@
 #define BADCHEESE 6
 #define BADTOMATO 7
 
+#define MAX(i) std::max(i,0)
+#define MIN(i) std::min(i,128)
 
 uLCD_4DGL lcd(p9,p10,p11);
 
-Stack::Stack() {
+Stack::Stack(int location, uLCD_4DGL * uLCD) {
+    x = location;
     Food bread(BREAD);
     stackOfFood = {bread};
+    lcd = uLCD;
+}
+
+void Stack::move(int dx) {
+    // constrain 
+    if (dx < 0) x = MAX(x + dx);
+    else x = MIN(x + dx);
 }
\ No newline at end of file