ZIWEI LIU
/
ELEC2645_Project_el19z2l
main.cpp
- Committer:
- alexliu0812
- Date:
- 2020-05-15
- Revision:
- 2:d621a4cbe0c2
- Parent:
- 1:11854f815cc8
- Child:
- 3:e53e289cd4ba
File content as of revision 2:d621a4cbe0c2:
/* ELEC2645 Embedded Systems Project School of Electronic & Electrical Engineering University of Leeds 2019/20 Name: ZiWei Liu Username: el19z2l Student ID Number: 201377806 Date: 2020.5.20 */ // includes #include "mbed.h" #include "Gamepad.h" #include "N5110.h" #include "DodgeEngine.h" #include "Character.h" #include "Block.h" #include "ctime" //objects Gamepad pad; N5110 lcd; DodgeEngine dodge; Character character; Block block; //prototypes void init(); void welcome(); void refreshing(); int main() { int fps=6; //initialize init(); welcome(); pad.leds_off(); refreshing(); wait(1.0f/fps); block.blockinit(); while (1) { dodge.dodgeupdate(); refreshing(); wait(1.0f/fps); } } void init(){ lcd.init(); pad.init(); } void welcome(){ //the start menu while(pad.A_pressed()==false){ lcd.printString(" Dodging!! " ,0,2); lcd.printString(" Press A ",0,4); lcd.refresh(); } //the instruction menu lcd.clear(); lcd.printString(" Instructions ",0,0); lcd.printString("Dodge the ball ",0,1); lcd.printString(" 3 chance! ",0,2); lcd.printString(" Good luck! ",0,4); lcd.printString("Press to start",0,5); lcd.refresh(); while(pad.start_pressed()==false){ pad.led(1,1); pad.led(3,1); pad.led(4,1); pad.led(6,1); } } void refreshing(){ lcd.clear(); dodge.charactermove(lcd,pad); dodge.blockmove(lcd); lcd.refresh(); }