Jahanzeb Ahmed Khan 201375614
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:Jahanzeb Ahmed Khan 00008 Username:el19jak 00009 Student ID Number:201375614 00010 Date:30 May 2020 00011 */ 00012 00013 // includes 00014 #include "mbed.h" 00015 #include "Gamepad.h" 00016 #include "N5110.h" 00017 #include "body.h" 00018 #include "food.h" 00019 #include "functions.h" 00020 00021 00022 // objects 00023 Gamepad pad; 00024 N5110 lcd; 00025 Food food; 00026 Body body; 00027 Functions functions; 00028 00029 void visual(); 00030 void start(); 00031 void init(); 00032 void snake_refresh(); 00033 00034 int main() 00035 { 00036 init(); 00037 start(); 00038 00039 for (;;) 00040 { 00041 snake_refresh(); 00042 body.game_end(lcd); 00043 body.food_eaten(lcd, pad, food); 00044 food.food_location(lcd); 00045 body.visual(lcd, pad, food); 00046 functions.output_score(lcd, pad, body, food); 00047 00048 wait(0.02); 00049 00050 } 00051 } 00052 00053 void init() 00054 { 00055 lcd.init(); 00056 pad.init(); 00057 body.init(); 00058 food.init(); 00059 00060 } 00061 00062 void snake_refresh() 00063 { 00064 body.user_input(pad); 00065 body.trail_delete(lcd); 00066 body.movement(); 00067 } 00068 00069 void start() 00070 { 00071 while (pad.A_held() == 0) 00072 { 00073 lcd.setContrast(0.5); 00074 lcd.drawCircle(42,24,22,FILL_TRANSPARENT); 00075 lcd.printString("Welcome to Snake",25,2); 00076 lcd.printString("Hold A to start",26,4); 00077 pad.tone(1500.0,1); 00078 wait(0.5); 00079 pad.tone(750.0,1); 00080 wait(0.5);/**Startup tone*/ 00081 pad.tone(1500.0,1); 00082 wait(0.5); 00083 pad.tone(750.0,1); 00084 00085 lcd.refresh(); 00086 } 00087 } 00088
Generated on Thu Aug 4 2022 17:12:13 by
1.7.2