Custom Game Controllers assembled in lab sessions and mounted with Nokia N5110 LCD display and a FRDM-K64F mbed plus various buttons, a joystick, potentiometer and piezo. Designed a game called 'Fruit Basket' to be played on the game controller where the player controls a basket and moves it catch objects that fall from random points along the top of the display to collect score.

Dependencies:   Basket Catch_Model Fruit Gamepad N5110 Objects mbed

Revision:
12:d87c9ae89472
Parent:
11:a6a88a51dd57
Child:
13:09a9ffd8eb60
diff -r a6a88a51dd57 -r d87c9ae89472 Project_Submission.cpp
--- a/Project_Submission.cpp	Tue Apr 18 14:29:05 2017 +0000
+++ b/Project_Submission.cpp	Wed Apr 19 14:35:27 2017 +0000
@@ -5,7 +5,7 @@
 
 #define BASKET_Y 41
 #define BASKET_WIDTH 12
-#define BALL_SPEED 3
+#define OBJECT_SPEED 1
 #define LIVES 5
 
 //OBJECTS//
@@ -14,11 +14,13 @@
 Catch_Model catchm;
 Objects objects;
 
+float speed;
+
 //FUNCTION PROTOTYPES//
 void init();
 void render();
 void welcome();
-void speed_select();
+float speed_select();
 
 //MAIN//
 int main()
@@ -38,6 +40,8 @@
             catchm.input(pad);
             catchm.update(lcd, pad);
             
+            //objects.move(speed_select());
+            
             catchm.check_a(lcd,pad);
             catchm.check_b(lcd,pad);
             catchm.check_x(lcd,pad);
@@ -46,7 +50,7 @@
             render();
             wait(1.0f/fps);
             
-           } while(lives > 0);
+           } while (lives > 0);
     }
 }
 
@@ -58,7 +62,7 @@
     pad.init();
      
     // initialise game model
-    catchm.init(BASKET_Y,BASKET_WIDTH,BALL_SPEED,LIVES);
+    catchm.init(BASKET_Y,BASKET_WIDTH,OBJECT_SPEED,LIVES);
 
 }
 
@@ -72,8 +76,8 @@
 
 void welcome() 
 {
-     
-    lcd.printString("  Press Start ",0,2);
+    lcd.printString("FRUIT BASKET",0,2); 
+    lcd.printString("press start",0,3);
     lcd.refresh();
      
     while (pad.check_event(Gamepad::START_PRESSED) == false) {
@@ -82,20 +86,18 @@
         pad.leds_off();
         wait(0.1);
     }
-    pad.tone(500, 0.5);
 }
 
-void speed_select()
+float speed_select()
 {
     lcd.clear();
     lcd.refresh();
     
     while (pad.check_event(Gamepad::START_PRESSED) == false) {
         
-        objects.speed_select(pad);
+        speed = objects.speed_select(pad);
         
         char buffer[14];
-        float speed = objects.get_speed();
         int print_speed = sprintf(buffer, "%10.2f", speed);
         
         if (speed > 1) {
@@ -105,4 +107,8 @@
         }
         lcd.refresh();
     }
+    
+    speed = objects.speed_select(pad);
+    objects.init(speed);    
+    return speed;
 }
\ No newline at end of file