Commit b8cc105a authored by Valentin Bartschies's avatar Valentin Bartschies
Browse files

Add Alien-Canon collision detection

parent b78cb148
......@@ -66,6 +66,10 @@ void calcGame() {
}
}
if (alienCanonColisionDetection()) {
playerLives = 0;
}
if (IsKeyPressed(KEY_K)) { // Placeholder, deleting Aliens one by one with "K"
for (int i = ALIEN_ROWS - 1; i >= 0; i--) {
for (int j = 0; j < ALIEN_COLS; j++) {
......@@ -144,3 +148,16 @@ bool allAliensDead() {
void alienDownward(void){
aliens->pos.y += 1;
}
bool alienCanonColisionDetection() {
for (int i = 0; i < ALIEN_ROWS; i++) {
for (int j = 0; j < ALIEN_COLS; j++) {
if (aliens->instances[j][i]->alive) {
if (CheckCollisionRecs( laserCanon, (Rectangle) {aliens->pos.x + j * (ALIEN_SIZE + ALIEN_OFFSET), aliens->pos.y + i * (ALIEN_SIZE + ALIEN_OFFSET), ALIEN_SIZE, ALIEN_SIZE})) {
return true;
}
}
}
}
return false;
}
\ No newline at end of file
......@@ -10,5 +10,6 @@ void alienCollisionDetection();
bool playerCollisionDetection(Projectile *proj);
bool allAliensDead();
void alienDownward(void);
bool alienCanonColisionDetection();
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