ELEC2645 (2017/18) / Mbed 2 deprecated el17yw

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
RickYu
Date:
Thu Apr 19 23:07:14 2018 +0000
Parent:
8:4a5e96ed2347
Child:
10:ef01b3076040
Commit message:
fix the problem that boom monney will go outside the screen;

Changed in this revision

boom/boom.cpp Show annotated file Show diff for this revision Revisions of this file
engine/engine.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
money/money.cpp Show annotated file Show diff for this revision Revisions of this file
rec/rect.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/boom/boom.cpp	Wed Apr 18 00:17:10 2018 +0000
+++ b/boom/boom.cpp	Thu Apr 19 23:07:14 2018 +0000
@@ -30,8 +30,9 @@
 {
     //set the falling speed of boom
     //let the boom move with set speed
-    boom_speed = 5;
+    boom_speed = 1;
     boom_y+= boom_speed; 
+
    
 }
 Vector2D boom::get_pos()
--- a/engine/engine.cpp	Wed Apr 18 00:17:10 2018 +0000
+++ b/engine/engine.cpp	Thu Apr 19 23:07:14 2018 +0000
@@ -60,8 +60,8 @@
     }
 
     //avoid money out of the screen
-    if (money_pos.x == 84) {
-        money_pos.x = 81;
+    if (money_pos.x+4 >= 84) {
+        money_pos.x = 80;
     }
     
     if (money_pos.x <2){
@@ -81,7 +81,7 @@
     }
     
     //avoid boom go outside of the screen
-    if (boom_pos.x == 84) {
+    if (boom_pos.x >= 82) {
         boom_pos.x = 81;
     }
     
@@ -112,7 +112,10 @@
     Vector2D rect_pos = _rect.get_pos();
     Vector2D money_pos = _money.get_pos();
     
-    if (boom_pos.y == 40 )
+    if (
+        (boom_pos.x >= rect_pos.x)) 
+    
+    
              
              {
             // money_pos.y = 0;   
--- a/main.cpp	Wed Apr 18 00:17:10 2018 +0000
+++ b/main.cpp	Thu Apr 19 23:07:14 2018 +0000
@@ -38,7 +38,7 @@
      engine.read_input(pad);
      engine.update(pad);
      render();
-     wait(1.0f/fps);
+     wait(0.1);
  }
      
 }
--- a/money/money.cpp	Wed Apr 18 00:17:10 2018 +0000
+++ b/money/money.cpp	Thu Apr 19 23:07:14 2018 +0000
@@ -27,8 +27,9 @@
 {
     //set the falling speed of money is 1
     //update the movement of money
-    money_speed = 1;
-    money_y+= money_speed; 
+    money_speed = 4;
+    money_y+= money_speed;
+
 }
 
 Vector2D money::get_pos()
--- a/rec/rect.cpp	Wed Apr 18 00:17:10 2018 +0000
+++ b/rec/rect.cpp	Thu Apr 19 23:07:14 2018 +0000
@@ -12,7 +12,7 @@
 void rect::init(int x,int y)
 {
     //set the rect move speed
-    rect_speed = 0.7;  // default speed
+    rect_speed = 1;  // default speed
 }
 
 void rect::draw(N5110 &lcd)
@@ -33,6 +33,7 @@
         rect_x-=rect_speed;
     } else if (d == E) {
         rect_x+=rect_speed;
+
     }
 }