![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
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
Project_Submission.cpp
- Committer:
- Nathanj94
- Date:
- 2017-04-04
- Revision:
- 7:32afc46c30f3
- Parent:
- 5:136b13a9b8b5
- Child:
- 8:1a785bfa4d08
File content as of revision 7:32afc46c30f3:
#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 #define LIVES 5 //OBJECTS// N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); Gamepad pad; Catch_Model catchm; //FUNCTION PROTOTYPES// void init(); void render(); void welcome(); //MAIN// int main() { int fps = 8; while(1) { init(); welcome(); render(); wait(1.0f/fps); int lives; do { catchm.input(pad); catchm.update(lcd, pad); lives = catchm.get_lives(); render(); wait(1.0f/fps); } while(lives > 0); } } //FUNCTIONS// void init() { // initialise LCD and Gamepad lcd.init(); pad.init(); // initialise game model catchm.init(BASKET_Y,BASKET_WIDTH,BALL_SPEED,LIVES); } void render() { // re-draw screen each loop lcd.clear(); catchm.draw(lcd); lcd.refresh(); } void welcome() { lcd.printString(" Press Start ",0,2); lcd.refresh(); while (pad.check_event(Gamepad::START_PRESSED) == false) { pad.leds_on(); wait(0.1); pad.leds_off(); wait(0.1); } }