Dependencies: mbed
On Minerva
Diff: main.cpp
- Revision:
- 6:dce38fe4e092
- Parent:
- 5:6774b7272e85
- Child:
- 7:c49f3d3b672f
--- a/main.cpp Tue Apr 14 06:39:11 2020 +0000 +++ b/main.cpp Tue Apr 28 15:54:41 2020 +0000 @@ -18,39 +18,75 @@ #include "PeopleEngine.h" #include "shot.h" + // objects Gamepad pad; N5110 lcd; PeopleEngine engine; shot shot; +//flag and triggers +Ticker ticker; +volatile int timer_flag = 0; + +// functions +void flip() { + timer_flag = 1; +} +void init(); +void control_people(); +void shot_update(); + int main() { //initial + init(); + + ticker.attach(&flip,5); + + //a infinite loop to control position of the people, update the game state + while(1) { + if(timer_flag == 1){ + timer_flag = 0; + if(shot._size < 30) + shot._size = shot._size + 2; + } + lcd.clear(); + // people + control_people(); + shot_update(); + lcd.refresh(); + //printf("shot refresh\n"); + //printf("size = %d\n",shot._size); + wait_ms(100);//fps = 10 + + } + +} + + +void init() +{ lcd.init(); lcd.setContrast(0.5); engine.init(); pad.init(); lcd.refresh(); - shot.init(lcd); - - //a infinite loop to control position of the people, update the game state - while(1) { - lcd.clear(); - // people - engine.read_input(pad); - engine.update(); - engine.draw(lcd); - // shot - //shot.gen_shot(); - //shot.draw(lcd); - shot.update(lcd); - lcd.refresh(); - printf("shot changes\n"); - wait_ms(200);//fps = 10 - - } - + shot.init(); } +void control_people() +{ + engine.read_input(pad); + engine.update(); + engine.draw(lcd); +} +void shot_update() +{ + shot.update(); + shot.delete_shot(); + shot.gen_shot(); + shot.draw(lcd); +} + \ No newline at end of file