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:
15:03868ddf5bf3
Parent:
14:e20bf6569607
Child:
16:d70fd9ff28b9
--- a/Project_Submission.cpp	Sat Apr 22 12:33:18 2017 +0000
+++ b/Project_Submission.cpp	Thu Apr 27 12:40:30 2017 +0000
@@ -21,7 +21,7 @@
 void init();
 void render();
 void welcome();
-void game_over();
+void game_over(int score);
 void instructions_general();
 void instructions_buttons();
 void set_brightness();
@@ -54,12 +54,14 @@
             catchm.check_b(lcd,pad);
 
             lives = catchm.get_lives();
+            if (lives == 0) {
+                game_over(basket.get_score());
+            }
+            
             render();
             wait(1.0f/fps);
             
            } while (lives > 0);
-           
-        game_over();
     }
 }
 
@@ -93,23 +95,23 @@
     }
 }
 
-void game_over()
+void game_over(int score)
 {
     lcd.clear();
     lcd.printString("   GAME OVER  ",0,2);
     
     char buffer[14];
-    int score = basket.get_score();
+    int _score = score;
     int print_score;
     
     if ((score == 0)||(score <= 9)) {
-        print_score = sprintf(buffer, "  Score: 000%d ", score);
+        print_score = sprintf(buffer, "  Score: 000%d ", _score);
     } else if (score <= 99) {
-        print_score = sprintf(buffer, "  Score: 00%2d ", score);
+        print_score = sprintf(buffer, "  Score: 00%2d ", _score);
     } else if (score <= 999 ) {
-        print_score = sprintf(buffer, "  Score: 0%3d ", score);
+        print_score = sprintf(buffer, "  Score: 0%3d ", _score);
     } else {
-        print_score = sprintf(buffer, "  Score: %4d ", score);
+        print_score = sprintf(buffer, "  Score: %4d ", _score);
     }   
     
     if (print_score <= 14) {
@@ -166,7 +168,7 @@
     lcd.refresh();
     
     while (pad.check_event(Gamepad::START_PRESSED) == false) {
-        lcd.setBrightness(pad.read_pot());
+        lcd.setBrightness(pad.read_pot()*10);
         pad.leds(pad.read_pot());
     }       
 }