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.
Revision 12:48e30c78ed26, committed 2018-05-05
- Comitter:
- ahmedhedait
- Date:
- Sat May 05 22:03:38 2018 +0000
- Parent:
- 11:80e9477d9330
- Child:
- 13:98489418ac30
- Commit message:
- I have now completed for the horizontal walls and the game is nearly finished.
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat May 05 21:10:27 2018 +0000
+++ b/main.cpp Sat May 05 22:03:38 2018 +0000
@@ -87,42 +87,9 @@
circx = 3;
}
- //lcd.drawRect(10,0,1,39,FILL_BLACK);
- //test 2
- /*
- if (
- (circy >= 3) && //top
- (circy <= 1 + 39) && //bottom
- (circx >= 10 - 3) && //left
- (circx <= 10 + 3) //right
- ) {
- // if it has, fix position and reflect x velocity
- //left
- if (circx <= 10-2) {
- if(circx >= 10 - 3) {
- circx = 10 - 3;
- }
- }
-
- //right
- if(circx >= 10 + 2) {
- if(circx <= 10 + 3) {
- circx = 10 + 3;
- }
- }
-
- if(circx >= 10 - 2 && circx <= 10 + 2) {
- if(circy < 2 + 39) {
- circy = 2 + 39;
- }
- }
- }
-
- */
//test 3
//lcd.drawRect(10,0,1,39,FILL_BLACK);
//lcd.drawRect(18,32,1,15,FILL_BLACK);
- //lcd.drawRect(18,25,18,1,FILL_BLACK);
//lcd.drawRect(36,25,1,25,FILL_BLACK);
//lcd.drawRect(45,18,1,30,FILL_BLACK);
@@ -169,6 +136,7 @@
c = 1;
d = 45;
}
+
if (
(circy >= b - 2) && //top
(circy <= 1 + b + d) && //bottom
@@ -204,47 +172,69 @@
}
+//lcd.drawRect(18,25,18,1,FILL_BLACK);
+// lcd.drawRect(18,18,27,1,FILL_BLACK);
+// lcd.drawRect(18,10,27,1,FILL_BLACK);
+ for (int i = 0; i <= 2; i++) {
+ //printf(" Stage %d\n", i);
+
+ if(i == 0) {
+ a = 18;
+ b = 25;
+ c = 18;
+ d = 1;
+ }
+ else if (i == 1) {
+ a = 18;
+ b = 18;
+ c = 27;
+ d = 1;
+ }
+
+ else if (i == 2) {
+ a = 18;
+ b = 10;
+ c = 27;
+ d = 1;
+ }
+
+ if (
+ (circy >= b - 2) && //top
+ (circy <= 1 + b) && //bottom
+ (circx >= a - 2) && //left
+ (circx <= a + 2 + c) //right
+ ) {
- //test 4
- //lcd.drawRect(10,0,1,39,FILL_BLACK);
- //lcd.drawRect(18,32,1,15,FILL_BLACK);
- /*
- a = 18;
- b = 32;
- c = 1;
- d = 15;
- if (
- (circy >= b - 2) && //top
- (circy <= 1 + b + d) && //bottom
- (circx >= a - 2) && //left
- (circx <= a + 2) //right
- ) {
- //left
- if (circx <= a - 2) {
- if(circx >= a - 3) {
- circx = a - 3;
+ //left
+ if (circx <= a - 2) {
+ if(circx >= a - 3) {
+ circx = a - 3;
+ }
+ }
+
+ //right
+ if(circx >= a + c) {
+ if(circx <= a + c + 3) {
+ circx = a + 3 + c;
+ }
+ }
+
+ //top
+ if(circy <= b - 2) {
+ if(circy >= b - 3)
+ circy = b - 3;
+ }
+
+ //bottom
+ if(circy >= b ) {
+ if(circy <= 3 + b )
+ (circy = 3 + b );
}
}
-
- //right
- if(circx >= a + 2) {
- if(circx <= a + 3) {
- circx = a + 3;
- }
- }
+ }
- if(circy <= b - 2) {
- if(circy >= b - 3)
- circy = b - 3;
- }
-
- if(circy >= 1 + b + d) {
- if(circy <= 1 + b + d)
- (circy = 1 + b + d);
- }
- }*/
if (circy == 41) {
@@ -265,4 +255,87 @@
wait(.05);
lcd.refresh();
}
-}
\ No newline at end of file
+}
+
+
+
+
+// TEST 100
+/* for (int i = 0; i <= 5; i++) {
+ //printf(" Stage %d\n", i);
+
+ if(i == 0) {
+ a = 10;
+ b = 0;
+ c = 1;
+ d = 39;
+
+ } else if (i == 1) {
+ a = 18;
+ b = 32;
+ c = 1;
+ d = 15;
+ }
+
+ else if (i == 2) {
+ a = 36;
+ b = 25;
+ c = 1;
+ d = 25;
+ }
+
+ else if(i == 3) {
+ a = 45;
+ b = 0;
+ c = 1;
+ d = 11;
+ }
+
+ else if (i == 4) {
+ a = 45;
+ b = 18;
+ c = 1;
+ d = 30;
+ }
+
+ else if (i == 5) {
+ a = 55;
+ b = 6;
+ c = 1;
+ d = 45;
+ }
+
+ if (
+ (circy >= b - 2) && //top
+ (circy <= 1 + b + d) && //bottom
+ (circx >= a - 2) && //left
+ (circx <= a + 2) //right
+ ) {
+ //left
+ if (circx <= a - 2) {
+ if(circx >= a - 3) {
+ circx = a - 3;
+ }
+ }
+
+ //right
+ if(circx >= a + 2) {
+ if(circx <= a + 3) {
+ circx = a + 3;
+ }
+ }
+
+ //top
+ if(circy <= b - 2) {
+ if(circy >= b - 3)
+ circy = b - 3;
+ }
+
+ //bottom
+ if(circy >= b + d) {
+ if(circy <= 2 + b + d)
+ (circy = 2 + b + d);
+ }
+ }
+ }
+ */
\ No newline at end of file