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:
- 11:e29b173ccb27
- Parent:
- 10:1c3bdbf2fe9f
- Child:
- 12:343704be6401
--- a/ModeA/ModeA.cpp Wed May 08 23:29:53 2019 +0000
+++ b/ModeA/ModeA.cpp Thu May 09 01:06:23 2019 +0000
@@ -27,11 +27,11 @@
speed = 0;
gravity = 1;
//variables for the bar
- screen_width = 80;
+ screen_width = 65;
bar_width = 10;
bar_speed = 2;
- //score = 1;
+ score = 0;
//generating random sizes of the bar
srand(time(NULL));
@@ -45,8 +45,9 @@
void ModeA::Bird(N5110 &lcd)
{
-
-
+ char buffer[14];
+ sprintf(buffer,"%2d",score);
+ lcd.printString(buffer,70,0);
lcd.drawRect(x_position, y_position,6,6,FILL_BLACK);
//lcd.drawRect(screen_width,0,bar_width,size_top,FILL_BLACK);
//lcd.drawRect(screen_width,48-size_bottom,bar_width,size_bottom,FILL_BLACK);
@@ -79,6 +80,8 @@
}
+
+
if (y_position < 0) {
@@ -126,20 +129,13 @@
- // wait(0.5);
- // }
-
-
- 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)) {
+ // wait(0.5);
+ // }
+
+
+
+
+ if ((screen_width == x_position)&& (size_top > y_position)) {
// size_top > y_position
// screen_width == x_position
lcd.clear();
@@ -154,15 +150,41 @@
bar_width = 0;
size_top = 0;
size_bottom = 0;
+
wait(0.5);
+ }
+
+
+ if ((screen_width == x_position)&& (size_top < y_position)) {
+
+ score = score + 1;
+ lcd.clear();
+ sprintf(buffer,"%2d",score);
+
+ }
+
-
+ 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)) {
+
+ // score = score + 1;
+
+
+ // }
@@ -188,17 +210,11 @@
// }
- if ((screen_width == x_position)&& (size_top < y_position)) {
- score = 1;
- lcd.clear();
- char buffer[14];
- sprintf(buffer,"% .2f ", score);
- lcd.printString(buffer,2,2);
- lcd.printString("Score =",1,1);
- lcd.refresh();
- wait(1.0);
-
- }
+ // if ((screen_width == x_position)&& (size_top < y_position)) {
+
+
+ // score = score + 1;
+ // }
// if ((screen_width == x_position)&& (size_bottom < (y_position - 6))) {
// }