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:
2:ada503e3486f
Parent:
0:7bd43e348502
Child:
3:69296f999fdf
--- a/Project_Submission.cpp	Fri Mar 17 15:36:20 2017 +0000
+++ b/Project_Submission.cpp	Sat Mar 18 14:06:55 2017 +0000
@@ -0,0 +1,60 @@
+///////// pre-processor directives ////////
+#include "mbed.h"
+#include "Gamepad.h"
+#include "N5110.h"
+#include "Catch_Model.h"
+
+#define BASKET_Y 41
+#define BASKET_WIDTH 12
+#define BALL_SPEED 3
+
+/////////////// structs /////////////////
+struct UserInput {
+    Direction d;
+    float mag;
+};
+/////////////// objects ///////////////
+N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
+Gamepad pad;
+Catch_Model catchm;
+///////////// prototypes ///////////////
+void init();
+void update_game(UserInput input);
+void render();
+///////////// functions ////////////////
+int main()
+{
+    int fps = 8;  // frames per second
+
+    init();
+
+    render();  // draw initial frame 
+    wait(1.0f/fps);  
+
+    // game loop - read input, update the game state and render the display
+    while (1) {
+        catchm.input(pad);
+        catchm.update(pad);
+        render();
+        wait(1.0f/fps);
+    }
+}
+
+void init()
+{
+    // need to initialise LCD and Gamepad 
+    lcd.init();
+    pad.init();
+     
+    // initialise the game
+    catchm.init(BASKET_Y,BASKET_WIDTH,BALL_SPEED);
+
+}
+
+void render()
+{
+    // clear screen, re-draw and refresh
+    lcd.clear();  
+    catchm.draw(lcd);
+    lcd.refresh();
+}