Skip to content

Commit

Permalink
Fixed last brick in array issue
Browse files Browse the repository at this point in the history
  • Loading branch information
kliao2016 committed Nov 14, 2017
1 parent 3a36301 commit c9044f8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
Binary file modified BrickBreaker.elf
Binary file not shown.
Binary file modified BrickBreaker.gba
Binary file not shown.
9 changes: 6 additions & 3 deletions game.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ void enableSlider(Slider *sldptr) {
* @param ballptr the pointer to the ball to move
*/
void createBall(int row, int col, int size, Ball *ballptr) {
ballptr->xDir = 1;
ballptr->yDir = -1;
ballptr->xDir = (rand() % 3) - 1;
if (ballptr->xDir == 0) {
ballptr->xDir = -1;
}
ballptr->yDir = 1;
ballptr->row = row;
ballptr->col = col;
ballptr->oldRow = ballptr->row;
Expand Down Expand Up @@ -198,7 +201,7 @@ void handleBrickCollisions(Brick *brptr, Ball *ballptr, int *numBricks, int bric
Brick *cur = brptr + i;
if (cur->isHit) {
drawRect(cur->row, cur->col, BRICKHEIGHT, BRICKWIDTH, BGCOLOR);
for (int j = i; j < bricksSize - 1; j++) {
for (int j = i; j < bricksSize; j++) {
brptr[j] = brptr[j + 1];
}
bricksSize = *(numBricks);
Expand Down
Binary file modified game.o
Binary file not shown.

0 comments on commit c9044f8

Please sign in to comment.