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:
- 6:85314a3d69cd
- Parent:
- 5:1a9d84df7207
- Child:
- 7:cf469c3505a2
--- a/main.cpp Sat May 04 10:49:53 2019 +0000
+++ b/main.cpp Mon May 06 09:37:34 2019 +0000
@@ -15,12 +15,15 @@
//#define GROUND_WIDTH 70
#define GROUND_HEIGHT 2
-#define GROUND_WIDTH 50
+//#define GROUND_WIDTH 50
#define BALL_SIZE 3
-#define LINE_HEIGHT 1
-#define LINE_WIDTH WIDTH
+//#define LINE_HEIGHT 1
+//#define LINE_WIDTH WIDTH
+int ground_width = 40;
+double ground_speed = 0.5;
+int level = 1;
struct UserInput {
@@ -35,11 +38,15 @@
void init();
void update_game(UserInput input);
void render();
+void Level();
+void welcome();
int main()
{
init();
+ welcome();
+ //Level();
render();
wait(0.1);
while (1) {
@@ -51,7 +58,11 @@
//falldown.read_input(pad);
//falldown.update(pad);
//render();
- falldown.init(GROUND_HEIGHT,BALL_SIZE,LINE_HEIGHT,LINE_WIDTH);
+ level = level++;
+ ground_width = ground_width + 2;
+ ground_speed = ground_speed + 0.2;
+ falldown.init(GROUND_HEIGHT,ground_width,BALL_SIZE,ground_speed);
+ //ground_width = ground_width + 10;
wait(0.1);
//clear lines
//redraw lines
@@ -68,8 +79,8 @@
{
lcd.init();
pad.init();
-
- falldown.init(GROUND_HEIGHT,BALL_SIZE,LINE_HEIGHT,LINE_WIDTH);
+
+ falldown.init(GROUND_HEIGHT,ground_width,BALL_SIZE,ground_speed);
}
void render()
@@ -77,6 +88,32 @@
lcd.clear();
falldown.draw(lcd);
+ char buffer[1];
+ sprintf(buffer,"%2d",level);
+ lcd.printString(buffer,1,1);
lcd.refresh();
}
+/*
+void Level()
+{
+ int level = 1;
+ char buffer[14];
+ sprintf(buffer,"%2d",level);
+ lcd.printString(buffer,0,0);
+}
+*/
+
+void welcome()
+{
+ lcd.printString("Falldown",0,1);
+ lcd.printString("Press Start",0,4);
+ lcd.refresh();
+
+ while ( pad.check_event(Gamepad::START_PRESSED) == false) {
+ pad.leds_on();
+ wait(0.1);
+ pad.leds_off();
+ wait(0.1);
+ }
+}