
Zeyu Feng 201377605
Dependencies: mbed
On Minerva
main.cpp
- Committer:
- el19zf
- Date:
- 2020-04-29
- Revision:
- 8:8287d2ef965d
- Parent:
- 7:c49f3d3b672f
- Child:
- 9:62d6559f0d50
File content as of revision 8:8287d2ef965d:
/* ELEC2645 Embedded Systems Project School of Electronic & Electrical Engineering University of Leeds 2019/20 Name:Zeyu Feng Username:el19zf Student ID Number:201377605 Date:11/3/2020 */ // includes #include "mbed.h" #include "Gamepad.h" #include "N5110.h" #include "People.h" #include "PeopleEngine.h" #include "shot.h" #include "Collision.h" // objects Gamepad pad; N5110 lcd; PeopleEngine engine; shot shot; Collision collision; //flag and triggers Ticker ticker; volatile int timer_flag = 0; // functions void flip() { timer_flag = 1; } void init(); void control_check(); void shot_update(); int main() { //initial init(); //set a ticker ticker.attach(&flip,2); //a infinite loop to control position of the people, update the game state while(1) { if(timer_flag == 1) { timer_flag = 0; if(shot.get_size() < 30){ int size = shot.get_size()+ 2; shot.set_size(size); } } lcd.clear(); // shot update shot_update(); // control people and check collision control_check(); lcd.refresh(); //printf("shot refresh\n"); //printf("size = %d\n",shot._size); wait_ms(200);//fps = 5 } } void init() { lcd.init(); lcd.setContrast(0.5); engine.init(); pad.init(); shot.init(); collision.init(); lcd.refresh(); } void control_check() { engine.read_input(pad); engine.update(); collision.set_pos(engine.get_pos()); if(collision.check(lcd)) { engine.init(); lcd.clear(); shot.init(); } collision.draw(lcd); engine.draw(lcd); } void shot_update() { shot.update(); shot.delete_shot(); shot.gen_shot(); shot.draw(lcd); }