Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 20:a36ab1560e73
- Parent:
- 19:5083339b55e8
- Child:
- 22:cded0cd8e1c9
diff -r 5083339b55e8 -r a36ab1560e73 main.cpp
--- a/main.cpp Thu May 21 17:07:46 2020 +0000
+++ b/main.cpp Fri May 22 03:54:22 2020 +0000
@@ -64,16 +64,18 @@
while(1) {
init();
init_value();
+ //select option by Joystick
interface.menu(lcd,pad);
switch(interface.get_menu_flag()){
case 0:
main_game(0.15,13);
break;
case 1:
- main_game(1,30);
+ main_game(1,35);
simp_game();
break;
case 2:
+ //define game parmeter by yourself
undefined();
break;
case 3:
@@ -102,7 +104,8 @@
// shot update
shot.draw(lcd);
- // set a count down and update lcd
+ // set a count down || generate and move the shots (shots won't move until count down to 0)
+ // check any collisions or victory
update(increment, max);
pad.leds_on();
@@ -137,6 +140,7 @@
void control_check()
{
+ //control the people by Joystick
engine.read_input(pad);
engine.update();
collision.set_pos(engine.get_pos());
@@ -154,11 +158,11 @@
void update(float increment, int max)
{
+ //if timeout_flag count down number and Joystick have been banned
if(timeout_flag){
control_check();
paused_flag = interface.check_pause(lcd,pad,paused_flag,increment,max);
}else{
- //if timeout_flag count down number and Joystick have been banned
interface.count_down(lcd);
pad.reset_buttons();
}
@@ -167,9 +171,8 @@
engine.draw(lcd,timeout_flag);
collision.draw(lcd);
}else{
- collision.set_check_col();
+ collision.reset_check_col();
}
- //printf("timeout_flag = %d\n",timeout_flag);
//check destination
if(collision.check_des(lcd)){
interface.victory(lcd,pad);
@@ -183,13 +186,16 @@
collision.draw_collision(lcd);
engine.init();
shot.init();
- //initialise time out,flag and bottons
+ //initialise timeout,flag and bottons
timeout.attach(&time_out,3);
timeout_flag = 0;
interface.set_count_down(18);
//count down, each duration 0.5s and 60 beats per minute(1s)
sound.count_sound(pad);
pad.reset_buttons();
+ #ifdef DEBUG
+ printf("initalises the timeout trigger\n");
+ #endif
}
void simp_game()
@@ -200,7 +206,7 @@
if(interface.get_sim_flag()){
init();
init_value();
- main_game(0.5,23);
+ main_game(0.3,20);
}
}
interface.init();
@@ -208,6 +214,7 @@
void undefined()
{
+ //define shots rate and maximum
interface.undefined_rate(lcd,pad);
interface.undefined_max(lcd,pad);
// 0 1 2 3 4 flag