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 Gamepad N5110
Revision 2:9f5714571c41, committed 2019-04-11
- Comitter:
- rafeh
- Date:
- Thu Apr 11 21:34:53 2019 +0000
- Parent:
- 1:beceda7046fb
- Child:
- 3:5409b50b01b0
- Commit message:
- Added the bird and made some start on the pipes
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Mar 29 19:27:10 2019 +0000
+++ b/main.cpp Thu Apr 11 21:34:53 2019 +0000
@@ -14,7 +14,8 @@
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
Gamepad pad;
-
+int xaxis=35;
+int yaxis=20;
const int bird [40][40] =
{
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@@ -60,16 +61,49 @@
};
+const int moving [9][9] =
+{
+ 0,0,0,0,0,0,0,0,0,
+ 0,0,0,1,1,0,0,0,0,
+ 0,0,1,1,1,1,0,0,0,
+ 0,1,1,1,1,1,1,0,0,
+ 0,1,1,1,1,1,1,1,1,
+ 0,1,1,1,1,1,1,1,1,
+ 0,1,1,1,1,1,1,1,0,
+ 0,0,1,1,1,1,1,0,0,
+ 0,0,0,1,1,1,0,0,0,
+
+ };
+
void welcome();
-
+void start(int xaxis,int yaxis);
int main() {
lcd.init();
pad.init();
lcd.clear();
lcd.setContrast(0.5);
welcome();
+ if (pad.check_event(Gamepad::START_PRESSED) == false) {
+ lcd.clear();
+
+ while(1) {
+ lcd.drawRect(0,44,84,4,FILL_BLACK);
+ int height = rand() % (20 + 1 - 2) + 2;
+ lcd.drawRect(40,0,5,height,FILL_BLACK);
+ lcd.drawSprite(xaxis,yaxis,9,9,(int*)moving);
+ yaxis=yaxis+2;
+ if (pad.check_event(Gamepad::A_PRESSED) == true) {
+ yaxis=yaxis-16;
+ }
+ wait(0.05);
+ //wait(0.1);
+ lcd.refresh();
+ lcd.clear();
+ }
+ }
+ }
-}
+
void welcome() {
lcd.drawSprite(0,0,40,40,(int*)bird);
@@ -84,9 +118,11 @@
pad.leds_off();
wait(0.1);
}
-
-
+ }
-
- }
+void start(int xaxis,int yaxis) {
+ lcd.refresh();
+ lcd.drawSprite(xaxis,yaxis,9,9,(int*)moving);
+ yaxis=yaxis-1;
+ }
\ No newline at end of file