ELEC2645 (2018/19) / Mbed 2 deprecated el17zl

Dependencies:   mbed

Fork of el17zl by Zhenwen Liao

Revision:
5:b50ce6160013
Parent:
4:750d3f9b54de
Child:
6:6b083e22cb53
diff -r 750d3f9b54de -r b50ce6160013 Ppl/Ppl.cpp
--- a/Ppl/Ppl.cpp	Tue Apr 09 08:31:27 2019 +0000
+++ b/Ppl/Ppl.cpp	Tue Apr 09 12:46:02 2019 +0000
@@ -34,18 +34,37 @@
     lcd.drawSprite(_x,_y,8,8,(int *)ppl);
 }
 
-void Ppl::check()
-{
-   
+void Ppl::update(int bb,int ba,int bx,int by)
+{   
+    if (bx ==0 && bb == 0 && by == 0 && ba == 0){
+        _x = _x;
+        _y = _y;
+        }
+    if (bx == 1){
+        _x = _x-8;
+        _y = _y;
+        }
+    if (bb == 1){
+        _x = _x+8;
+        _y = _y;
+        }
+    if (by == 1){
+        _y = _y-8;
+        _x = _x;
+        }
+    if (ba == 1){
+        _y = _y+8;
+        _x = _x;
+        }
     // check the y origin to ensure that the paddle doesn't go off screen
     if (_y < 4) {
         _y = 4;
     }
-    if (_y > 37) {
-        _y = 37;
+    if (_y > 36) {
+        _y = 36;
     }
-    if (_x > 75) {
-        _x = 75;
+    if (_x > 74) {
+        _x = 74;
     }
     if (_x < 2) {
         _x = 2;