Added game end logic check, made sure bricks are working

This commit is contained in:
Joe Adams 2018-01-12 08:48:38 +00:00
parent 6be9da289c
commit bed7e9a8c1
2 changed files with 9 additions and 2 deletions

View File

@ -294,6 +294,11 @@ int main(void) {
updateScore(&playerScore, &bricks, &brickCount, &level, &theBall);
}
if (level > 3) {
printf("Congratulations! You won!\n");
go = 0;
}
if (step % (subSteps+1) == 0) {
//step = 0;
/*
@ -348,6 +353,8 @@ int main(void) {
SDL_DestroyWindow(window1);
SDL_Quit();
printf("Your score was: %d, with %d lives remaining\n", playerScore, playerLives);
return 0;
}
@ -419,7 +426,7 @@ void updateScore(int *playerScore, brick *bricks, int *brickCount, int *level, b
break;
}
} else {
allBricksDestroyed = 0;
if (bricks[i].brickType<5) allBricksDestroyed = 0; // Excludes 'power-up bricks' from having to be destroyed before moving on to the next level
}
}
if (allBricksDestroyed==1) {

View File

@ -116,7 +116,7 @@ void initialiseBricks(brick *bricks, int *brickCount, int level) {
bricks[109] = (brick) { .brickType = 4, .x = 369, .y = 214, .width = 30, .height = 10, .destroyed = 0 };
bricks[110] = (brick) { .brickType = 4, .x = 401, .y = 214, .width = 30, .height = 10, .destroyed = 0 };
bricks[111] = (brick) { .brickType = 4, .x = 433, .y = 214, .width = 30, .height = 10, .destroyed = 0 };
*brickCount = 1;
*brickCount = 112;
break;
case 2:
bricks[0] = (brick) { .brickType = 1, .x = 290, .y = 240 - 370, .width = 8, .height = 8, .destroyed = 0 };