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: ModeA/ModeA.cpp
- Revision:
- 9:571f92b0211b
- Parent:
- 8:d9b602e58126
- Child:
- 10:1c3bdbf2fe9f
- Child:
- 14:558c85380f84
--- a/ModeA/ModeA.cpp Wed May 08 19:15:06 2019 +0000 +++ b/ModeA/ModeA.cpp Wed May 08 20:27:31 2019 +0000 @@ -21,7 +21,7 @@ void ModeA::initialise(N5110 &lcd) { - x_position = 5; + x_position = 12; y_position = 18; speed = 1; gravity = 1; @@ -31,13 +31,16 @@ bar_speed = 2; - size_top = 10; - size_bottom = 7; + + srand(time(NULL)); + size_top = rand() % 15; + srand(time(NULL)); + size_bottom = rand() % 15; - } - + + } -void ModeA::Bird(N5110 &lcd) +void ModeA::Bird(N5110 &lcd) { @@ -73,6 +76,8 @@ wait(0.5); } + + if (y_position < 0) { y_position = 0; @@ -88,36 +93,73 @@ lcd.drawRect(screen_width,48-size_bottom,bar_width,size_bottom,FILL_BLACK); lcd.refresh(); - if (screen_width > 50) { - srand(time(NULL)); - size_top = rand() % 48; - srand(time(NULL)); - size_bottom = rand() % 48; + // if (screen_width > 50) { + // srand(time(NULL)); + // size_top = rand() % 48; + // srand(time(NULL)); + // size_bottom = rand() % 48; // bar_width = 50; // bar_speed = 0; - } + // } - if (screen_width == 5) { - srand(time(NULL)); - size_top = rand() % 48; - srand(time(NULL)); - size_bottom = rand() % 48; - } + // if (screen_width == 5) { + // srand(time(NULL)); + // size_top = rand() % 15; + // srand(time(NULL)); + // size_bottom = rand() % 15; + // } + // if (screen_width == 11) { + // lcd.clear(); + // lcd.printString("GAME OVER",6,2); + // lcd.printString("Press BACK",6,4); + // pad.tone(2000.0,0.3); + // lcd.refresh(); + // bar_speed = 0; + // speed = 0; + // gravity = 0; + // y_position = 48; + // bar_width = 0; + // size_top = 0; + // size_bottom = 0; + + + + // wait(0.5); + // } - if (size_top == 5) { - lcd.clear(); - lcd.printString("GAME OVER",6,2); - lcd.printString("Press BACK",6,4); + if ( pad.check_event(Gamepad::X_PRESSED) == true) { + + srand(time(NULL)); + size_top = rand() % 15; + srand(time(NULL)); + size_bottom = rand() % 15; + + } + + if ((screen_width == x_position)&& (size_top > y_position)) { + // size_top > y_position + // screen_width == x_position + lcd.clear(); + lcd.printString("GAME OVER",6,2); + lcd.printString("Press BACK",6,4); pad.tone(2000.0,0.3); - lcd.refresh(); - bar_speed = 0; - speed = 0; - gravity = 0; - y_position = 48; - wait(0.5); + lcd.refresh(); + bar_speed = 0; + speed = 0; + gravity = 0; + y_position = 48; + bar_width = 0; + size_top = 0; + size_bottom = 0; - } + + + wait(0.5); + + } + + screen_width = screen_width - bar_speed; wait(0.1);