Calum Johnston / Mbed 2 deprecated BrickBreaker

Dependencies:   N5110 PinDetect PowerControl mbed

Files at this revision

API Documentation at this revision

Comitter:
el13cj
Date:
Thu May 07 18:01:40 2015 +0000
Parent:
8:7889867308d3
Child:
10:19c6aba3beec
Commit message:
FIXED ball strike-through error; INTERMITTENT fail to destroy brick, persistent menu on game start; TODO (if can) spkr, clear high scores, ball speed select

Changed in this revision

BrickBreaker.cpp Show annotated file Show diff for this revision Revisions of this file
BrickBreaker.h Show annotated file Show diff for this revision Revisions of this file
--- a/BrickBreaker.cpp	Thu May 07 17:20:11 2015 +0000
+++ b/BrickBreaker.cpp	Thu May 07 18:01:40 2015 +0000
@@ -1,8 +1,9 @@
 /**
-@file BrickBreaker.cpp
-
-@brief Function implementations
-
+*   @file BrickBreaker.cpp
+*
+*   @brief Function implementations
+*   @brief Credits to Craig A. Evans for his implementation of the 2-axis Joystick.
+*
 */
 
 
@@ -140,7 +141,6 @@
     dispScore();
     dispLives();
     ball();
-    doBricks();
     } else if (g == 0) {
     }
 }
@@ -441,7 +441,7 @@
 {
 
     if (bricks[y][x]) {
-        for (int a = -1; a < 7; a++) {
+        for (int a = -1; a < 8; a++) {
             if (lcd.getPixel(bricksx[x]+a,bricksy[y]-1)) {
                 clearFlag[y][x] = 1;
                 bricks[y][x] = 0;
@@ -450,7 +450,7 @@
                 bricks[y][x] = 0;
             }
         }
-        for (int b = 0; b < 3; b++) {
+        for (int b = -1; b < 3; b++) {
             if (lcd.getPixel(bricksx[x]-1,bricksy[y]+b)) {
                 clearFlag[y][x] = 1;
                 bricks[y][x] = 0;
@@ -758,22 +758,20 @@
 void ball()
 
 {
-    int e = d;    
-    
-    setAngle();
+    int e = d;
+
+    setAngle(); //check what ball is touching get new angle
+    doBricks(); //check what bricks are touching clear all necessary
+    moveBall1(d); //move ball with new angle
+    wait_ms(25); //wait
 
-    doBricks();
-    moveBall1(d);
-    wait_ms(25);
-    
-    if (d != e) return;   
-        
-    setAngle();
-    doBricks();
+    if (d == e) {
 
-    moveBall2(d);
-    wait_ms(25);
-    
+        setAngle();
+        doBricks();
+        moveBall2(d);
+        wait_ms(25);
+    }
 }
 
 void moveBall1(int d)   //move the ball, quantised into 16 directions of motion
--- a/BrickBreaker.h	Thu May 07 17:20:11 2015 +0000
+++ b/BrickBreaker.h	Thu May 07 18:01:40 2015 +0000
@@ -1,8 +1,9 @@
 /**
-@file BrickBreaker.h
-
-@brief Header file containg function prototypes and variables
-
+*   @file BrickBreaker.h
+*
+*   @brief Header file containg function prototypes and variables
+*   @brief Credits to Craig A. Evans for his implementation of the 2-axis Joystick.
+*
 */
 
 
@@ -540,6 +541,4 @@
 *   
 *   Displays the dreaded Game Over screen. If the score is greater than any of the high scores they will be updated accordingly and the player informed.
 */
-void gameOver();
-
-
+void gameOver();
\ No newline at end of file