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:
- 7:9a30314fa41f
- Parent:
- 6:f7484a2f32fd
--- a/ModeA/ModeA.cpp Wed May 08 17:06:02 2019 +0000 +++ b/ModeA/ModeA.cpp Wed May 08 18:33:28 2019 +0000 @@ -26,13 +26,20 @@ // speed = pad.read_pot(); gravity = 1; - screen_width = 50; - bar_width = 10; + screen_width = 80; + bar_width = 6; + speed = 1; bar_speed = 2; size_top = 10; size_bottom = 7; + + srand(time(NULL)); + size_top = rand() % 48; + srand(time(NULL)); + size_bottom = rand() % 48; + } @@ -50,7 +57,7 @@ if ( pad.check_event(Gamepad::Y_PRESSED) == true) { - speed = pad.read_pot(); + speed = speed - gravity*5; } @@ -73,6 +80,14 @@ wait(0.5); } + + + if (screen_width == 3) { + srand(time(NULL)); + size_top = rand() % 48; + srand(time(NULL)); + size_bottom = rand() % 48; + } if (y_position < 0) { y_position = 0; @@ -84,28 +99,23 @@ wait(0.1); - lcd.drawRect(screen_width,0,bar_width,size_top,FILL_BLACK); - lcd.drawRect(screen_width,48-size_bottom,bar_width,size_bottom,FILL_BLACK); - lcd.refresh(); + // lcd.drawRect(screen_width,0,bar_width,size_top,FILL_BLACK); + // lcd.drawRect(screen_width,48-size_bottom,bar_width,size_bottom,FILL_BLACK); + //lcd.refresh(); - if (bar_width > 50) { - srand(time(NULL)); - size_top = rand() % 48; - srand(time(NULL)); - size_bottom = rand() % 48; + // if (bar_width > 50) { + // srand(time(NULL)); + // size_top = rand() % 48; + //srand(time(NULL)); + // size_bottom = rand() % 48; // bar_width = 50; // bar_speed = 0; - } + //} - if (bar_width == 0) { - srand(time(NULL)); - size_top = rand() % 48; - srand(time(NULL)); - size_bottom = rand() % 48; - } + - if (size_top == 5 ) { + if ((size_top > (y_position - 6)) && (screen_width == 11)) { lcd.clear(); lcd.printString("GAME OVER",6,2); lcd.printString("Press BACK",6,4); @@ -118,10 +128,32 @@ wait(0.5); } + + + // if (screen_width == 3) { + // srand(time(NULL)); + // size_top = rand() % 48; + // srand(time(NULL)); + // size_bottom = rand() % 48; + // } - screen_width = screen_width - bar_speed; + screen_width = screen_width - bar_speed; wait(0.1); + lcd.drawRect(screen_width,0,bar_width,size_top,FILL_BLACK); + lcd.drawRect(screen_width,48-size_bottom,bar_width,size_bottom,FILL_BLACK); + + lcd.refresh(); + + + // if (screen_width == 3) { + // srand(time(NULL)); + // size_top = rand() % 48; + // srand(time(NULL)); + // size_bottom = rand() % 48; + // } + // screen_width = screen_width - bar_speed; + wait(0.1); }