Commit 75fd37d0 authored by Valentin Bartschies's avatar Valentin Bartschies
Browse files

Add gameover if aliens reach bottom

parent b8cc105a
......@@ -66,7 +66,7 @@ void calcGame() {
}
}
if (alienCanonColisionDetection()) {
if (alienCanonColisionDetection() || alienReachedBottom()) {
playerLives = 0;
}
......@@ -160,4 +160,17 @@ bool alienCanonColisionDetection() {
}
}
return false;
}
bool alienReachedBottom() {
for (int i = 0; i < ALIEN_ROWS; i++) {
for (int j = 0; j < ALIEN_COLS; j++) {
if (aliens->instances[j][i]->alive) {
if ((aliens->pos.y + i * (ALIEN_SIZE + ALIEN_OFFSET) + ALIEN_SIZE) >= GAME_SCREEN_HEIGHT) {
return true;
}
}
}
}
return false;
}
\ No newline at end of file
......@@ -11,5 +11,6 @@ bool playerCollisionDetection(Projectile *proj);
bool allAliensDead();
void alienDownward(void);
bool alienCanonColisionDetection();
bool alienReachedBottom();
void spawnPlayerProjectile();
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment