//Look for collisions based on invader and player rectangles int enemy_player_collision() { int i,j,c; for(i = 0; i < ROW_INVADERS; i++) { for(j = 0; j < COL_INVADERS; j++) { if (invaders.enemy[i][j].alive == 1) { c = collision(player.hitbox, invaders.enemy[i][j].hitbox); if (c == 1) { player.lives--; pause_for(500); init_invaders(); init_bases(); return 1; } } } } return 0; }
//Determine game level void calculate_level() { if (invaders.killed != 0 && invaders.killed % 11 == 0) { score.level++; init_bases(); init_misil(); init_invaders(); init_saucer(); pause_for(500); } }
//Procura por colisões baseado nos tiros dos inimigos e no jogador //Look for collisions based on enemy bullet and player rectangles void player_hit_collision() { int i,c; for(i = 0; i < E_BULLETS; i++) { if (e_bullets[i].alive == 1) { c = collision(e_bullets[i].hitbox, player.hitbox); if (c == 1) { if (player.lives >= 0) { player.lives--; pause_for(500); } } } } }
//Look for collisions based on enemy bullet and player rectangles void player_hit_collision() { int i,c; for(i = 0; i < E_BULLETS; i++) { if (enemy_bullets[i].alive == 1) { c = collision(enemy_bullets[i].hitbox, player.hitbox); if (c == 1) { if (player.lives >= 0) { enemy_bullets[i].alive = 0; //Bullet dissapear when hit player player.lives--; pause_for(500); draw_serviceProjectMatch(match); } } } } }