Added game end logic check, made sure bricks are working
This commit is contained in:
parent
6be9da289c
commit
bed7e9a8c1
@ -293,6 +293,11 @@ int main(void) {
|
||||
updateBall(tickrate, &theBall, &thePaddle, winWidth, winHeight, &bricks, brickCount, &playerLives);
|
||||
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) {
|
||||
|
||||
@ -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 };
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user