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 ELEC2645_Project_el18to
Diff: main.cpp
- Revision:
- 5:3fda09f927b8
- Parent:
- 4:536a62daa959
- Child:
- 6:314240662849
--- a/main.cpp Sat May 02 09:52:17 2020 +0000
+++ b/main.cpp Sun May 03 12:41:07 2020 +0000
@@ -110,8 +110,11 @@
volatile int i = 2000;
volatile int i1 = 500;
volatile int is = 30;
-volatile int iis = 0;
+volatile int iis;
volatile int g = 0;
+volatile int length1;
+volatile int length2;
+volatile int tt;
void start_page();
void check_start();
@@ -135,13 +138,22 @@
lcd.init();
lcd.setContrast(0.5);
pad.init();
- check_start();
while(1) {
- pad.leds_on();
- lcd.clear();
- game();
- lcd.refresh();
- wait_ms(30);
+ check_start();
+ while(g != 50) {
+ pad.leds_on();
+ lcd.clear();
+ game();
+ lcd.refresh();
+ wait_ms(30);
+ }
+ while(pad.start_pressed() == false) {
+
+ }
+ game_over();
+ g = 0;
+ xw = 4;
+ yw = 17;
}
}
@@ -499,6 +511,7 @@
check_crash();
if (i >= 3500) {
+ g = 50;
game_over();
}
}
@@ -511,6 +524,7 @@
check_crash();
if (is <= 0) {
+ g = 50;
game_over();
}
}
@@ -532,6 +546,9 @@
lcd.refresh();
lcd.printString("GAME OVER!",12,2);
lcd.printString("Press start",10,4);
+ i = 2000;
+ i1 = 500;
+ is = 30;
}
void count1()
@@ -564,15 +581,13 @@
void count2()
{
+ char buffer1[5];
+ char buffer2[3];
bool cou = pad.B_held();
bool couu = pad.B_pressed();
bool cu = pad.Y_held();
bool cuu = pad.Y_pressed();
- int length1;
- int length2;
- char buffer1[5];
- char buffer2[3];
length1 = sprintf(buffer1, "%2dM", i1);
length2 = sprintf(buffer2, "%2dS", is);
if(length1 <= 5) {
@@ -593,12 +608,10 @@
lcd.printString(buffer2,61,0);
}
- if(iis >= 0) {
- wait_ms(1);
- iis = iis + 1;
- }
- if(iis = 1000) {
- iis = 0;
- is = is - 1;
+ iis = 30;
+ tt = tt + 1;
+ if(iis == tt){
+ tt = 0;
+ is = is - 1;
}
}
\ No newline at end of file