201377806 ZiWei Liu
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 /** 00002 ELEC2645 Embedded Systems Project 00003 School of Electronic & Electrical Engineering 00004 University of Leeds 00005 2019/20 00006 00007 Name: ZiWei Liu ,Alex 00008 Username: el19z2l 00009 Student ID Number: 201377806 00010 Date: 2020.5.20 00011 */ 00012 00013 // includes 00014 #include "mbed.h" 00015 #include "Gamepad.h" 00016 #include "N5110.h" 00017 #include "DodgeEngine.h" 00018 #include "Character.h" 00019 #include "Block.h" 00020 00021 #define x1up 80 00022 #define y1up 1 00023 #define x1down 80 00024 #define y1down 15 00025 #define x2up 80 00026 #define y2up 35 00027 #define x2down 80 00028 #define y2down 46 00029 #define manx 15 00030 #define many 1 00031 00032 //objects 00033 Gamepad pad; 00034 N5110 lcd; 00035 DodgeEngine dodge; 00036 Character character; 00037 Block block; 00038 00039 //prototypes 00040 void init(); 00041 void welcome(); 00042 void refreshing(); 00043 00044 int main() 00045 { 00046 int fps=6; 00047 00048 //initialize 00049 init(); 00050 welcome(); 00051 00052 00053 pad.leds_off(); 00054 wait(1.0f/fps); 00055 00056 //initate 00057 dodge.init(x1up, y1up, x1down, y1down, x2up, y2up,x2down,y2down, manx, many); 00058 while (1) { 00059 refreshing(); 00060 wait(1.0f/fps); 00061 } 00062 } 00063 00064 00065 void init(){ 00066 00067 lcd.init(); 00068 pad.init(); 00069 00070 } 00071 00072 void welcome(){ 00073 //the start menu 00074 while(pad.A_pressed()==false){ 00075 lcd.printString(" Dodging!! " ,0,2); 00076 lcd.printString(" Press A ",0,4); 00077 lcd.refresh(); 00078 } 00079 00080 //the instruction menu 00081 lcd.clear(); 00082 lcd.printString(" Instructions ",0,0); 00083 lcd.printString("Dodge the walls ",0,1); 00084 lcd.printString("Hold A to move ",0,2); 00085 lcd.printString(" 4 levels! ",0,3); 00086 lcd.printString(" Good luck! ",0,4); 00087 lcd.printString("Press start",0,5); 00088 lcd.refresh(); 00089 00090 while(pad.start_pressed()==false){ 00091 pad.led(1,1); 00092 pad.led(3,1); 00093 pad.led(4,1); 00094 pad.led(6,1); 00095 } 00096 } 00097 00098 void refreshing(){ 00099 00100 lcd.clear(); 00101 dodge.dodgeupdate(lcd,pad,x1up, y1up, x1down, y1down, x2up, y2up,x2down,y2down,manx, many); 00102 dodge.charactermove(lcd,pad); 00103 dodge.blockmove(lcd); 00104 lcd.refresh(); 00105 00106 }
Generated on Sat Jul 16 2022 00:49:04 by
1.7.2