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

Adding Alien Colision detection

parent f774be86
......@@ -44,11 +44,24 @@ void calcGame() {
}
if (playerProj) {
if (playerProj->pos.y > 1.0) {
for (int i = 0; i < ALIEN_ROWS; i++) {
for (int j = 0; j < ALIEN_COLS; j++) {
if (aliens->instances[j][i]->alive) {
if (CheckCollisionPointRec(playerProj->pos, (Rectangle) {aliens->instances[j][i]->pos.x, aliens->instances[j][i]->pos.y, ALIEN_SIZE, ALIEN_SIZE})) {
aliens->instances[j][i]->alive = false;
playerProj->pos.y = 0;
}
}
}
}
}
playerProj = projectileTick(playerProj);
} else if (IsKeyPressed(KEY_SPACE)) {
spawnPlayerProjectile();
}
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++) {
......
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