Uses accompanying Basket, Objects and Fruit libraries to create Fruit Basket game. If an object is caught, points are added; if an object in missed, a 'life' is lost.

Dependents:   Game_Controller_Project

Revision:
9:902b67101cdc
Parent:
8:db24c475f64f
Child:
10:6605cd9d374b
--- a/Catch_Model.cpp	Fri Apr 14 15:37:08 2017 +0000
+++ b/Catch_Model.cpp	Sat Apr 15 15:06:54 2017 +0000
@@ -17,6 +17,7 @@
     _objects_speed = objects_speed;
     _lives = lives;
     _delay = 1;
+    _bullet_time = 0;
     
     basket.init(_basket_y, _basket_width);
     objects.init(_objects_speed);
@@ -34,7 +35,11 @@
     check_basket_miss(lcd, pad);
     
     basket.move(_d, _mag, pad);
-    objects.move();
+    if (_bullet_time == 1) {
+        objects.bullet_time();
+    } else {
+        objects.move(pad);
+    }
 }
 
 void Catch_Model::draw(N5110 &lcd)
@@ -55,8 +60,8 @@
     
     if(
        (o_y_pos >= b_y_pos) &&
-       (o_x_pos > b_x_pos) &&
-       (o_x_pos <= (b_x_pos + 5))
+       (o_x_pos >= b_x_pos) &&
+       (o_x_pos <= (b_x_pos + 6))
        ) {
            pad.tone(1000, 0.2);
            objects.undraw(lcd);
@@ -67,9 +72,7 @@
 
 void Catch_Model::check_basket_miss(N5110 &lcd, Gamepad &pad)
 {
-   int b_x_pos = basket.get_x();
    int b_y_pos = basket.get_y();
-   int o_x_pos = objects.get_x();
    int o_y_pos = objects.get_y();
    
    int score_var;
@@ -79,10 +82,10 @@
        objects.undraw(lcd);
        if (score_var != 5) {
            _lives--;
-        }
+          }
         pad.tone(100, 0.2);
         objects.init(_objects_speed);
-   } 
+      } 
 }
 
 void Catch_Model::check_a(N5110 &lcd, Gamepad &pad)
@@ -91,11 +94,11 @@
         (pad.check_event(Gamepad::A_PRESSED) == true) &&
         (_delay == 1)
         ) {
-        objects.undraw(lcd);
-        objects.init(_objects_speed);
+            objects.undraw(lcd);
+            objects.init(_objects_speed);
         
-        _delay = 0;
-        timeout.attach(this, &Catch_Model::set_delay, 10.0);
+            _delay = 0;
+            timeout.attach(this, &Catch_Model::set_delay, 10.0);
         }
     
 }
@@ -106,14 +109,36 @@
         (pad.check_event(Gamepad::B_PRESSED) == true) &&
         (_delay == 1)
         ) {
-        _lives++;
+            _lives++;
         
-        _delay = 0;
-        timeout.attach(this, &Catch_Model::set_delay, 10.0);
+            _delay = 0;
+            timeout.attach(this, &Catch_Model::set_delay, 10.0);
         }
     
 }
 
+void Catch_Model::check_x(N5110 &lcd, Gamepad &pad)
+{
+    if (
+        (pad.check_event(Gamepad::X_PRESSED) == true) &&
+        (_delay == 1)
+        ) { 
+            /*
+            int b_y_pos = basket.get_y();
+            int o_y_pos = objects.get_y();
+            
+            do {
+                _bullet_time = 1;
+                } while (o_y_pos < b_y_pos);
+                
+            _bullet_time = 0; 
+            */
+            _delay = 0;
+            timeout.attach(this, &Catch_Model::set_delay, 10.0);  
+        }    
+                
+}
+
 void Catch_Model::set_delay()
 {
     _delay = 1;