
Zeyu Feng 201377605
Dependencies: mbed
On Minerva
Diff: main.cpp
- Revision:
- 12:009895f6b6e4
- Parent:
- 11:494cc44777fe
- Child:
- 13:eb60628db8bf
--- a/main.cpp Mon May 11 09:09:31 2020 +0000 +++ b/main.cpp Mon May 11 14:43:16 2020 +0000 @@ -19,6 +19,7 @@ #include "shot.h" #include "Collision.h" #include "Interface.h" +#include "tests.h" // objects Gamepad pad; @@ -47,9 +48,11 @@ void init_timeout(); void main_game(float,int); void init_value(); +void simp_game(); int main() { + int failures = run_all_tests(); //initial init(); @@ -66,6 +69,7 @@ break; case 1: main_game(4,40); + simp_game(); break; case 2: interface.exit(lcd,pad); @@ -97,7 +101,7 @@ //printf("size = %d\n",shot._size); wait_ms(1000/6);//fps = 6 } - printf("END GAME\n"); + //printf("END GAME\n"); } void init() @@ -122,10 +126,8 @@ interface.game_over(lcd,pad); lcd.clear(); } else{ - engine.init(); + init_timeout(); lcd.clear(); - shot.init(); - init_timeout(); } } } @@ -157,7 +159,20 @@ void init_timeout() -{ +{ + lcd.clear(); + lcd.drawRect(1,1,(collision.get_health()+1)*2,3,FILL_BLACK); + lcd.drawRect(0,0,WIDTH,HEIGHT,FILL_TRANSPARENT); + lcd.refresh(); + wait(0.5); + lcd.clear(); + lcd.drawRect(1,1,collision.get_health()*2,3,FILL_BLACK); + lcd.drawRect(0,0,WIDTH,HEIGHT,FILL_TRANSPARENT); + lcd.refresh(); + wait(0.5); + engine.init(); + shot.init(); + //initialise time out timeout.attach(&time_out,3); timeout_flag = 0; count_flag = 18; @@ -170,4 +185,16 @@ count_flag = 18; paused_flag = 0; option_flag = 0; -} \ No newline at end of file +} + +void simp_game() +{ + if(!interface.get_victory_flag()){ + interface.simple_game(lcd,pad); + if(interface.get_sim_flag()){ + init(); + main_game(2.5,30); + } + } + interface.init(); +} \ No newline at end of file