ELEC2645 (2017/18) / Mbed 2 deprecated el17yw

Dependencies:   mbed

Revision:
25:1d91ab97d86a
Parent:
24:14489d259ffb
diff -r 14489d259ffb -r 1d91ab97d86a rec/rect.cpp
--- a/rec/rect.cpp	Mon Apr 30 16:40:32 2018 +0000
+++ b/rec/rect.cpp	Mon Apr 30 18:07:51 2018 +0000
@@ -1,5 +1,4 @@
 #include "rect.h"
-
 rect::rect()
 {
 
@@ -9,9 +8,10 @@
 {
 
 }
+
 void rect::init()
 {
-    rect_speed = 1;  // default speed
+    rect_speed = 1;  // set the initial speed
 }
 
 void rect::draw(N5110 &lcd)
@@ -22,39 +22,41 @@
   
 }
 
-void rect::update(Direction d,float mag)
+void rect::update(Direction d)
 {
     
-    rect_speed = int(mag*10.0f);  // scale is arbitrary
-    
     //control the movement of rect when joystick moves
-    //movement of north and south are not allowed
       if (d == W) {
         rect_x-=rect_speed;
-    } else if (d == E) {
+        } 
+      else if (d == E) {
         rect_x+=rect_speed;
+        }
+}
 
-    }
+
+void rect::init_score()
+{
+    rect_score = 0; //using this function when game over
 }
 
 void rect::add_score()
 {
     rect_score++;
 }
-void rect::init_score()
-{
-    rect_score = 0;
-}
+
 void rect::minus_score()
 {
     rect_score--;
 }
+
 int rect::get_score()
 {
     return rect_score;
 }
 
-Vector2D rect::get_pos() {
+Vector2D rect::get_pos() 
+{
     Vector2D p = {rect_x};
     return p;    
 }
@@ -62,7 +64,4 @@
 void rect::set_pos(Vector2D p)
 {
     rect_x = p.x;
-}
-
-
-
+}
\ No newline at end of file