void move_bullets(void) { BULLET *bullet = bullet_list; while (bullet) { bullet->y -= BULLET_SPEED; /* if the bullet is at the top of the screen, delete it */ if (bullet->y < 8) { bullet = delete_bullet(bullet); goto bullet_updated; } else { /* shot an asteroid? */ if (asteroid_collision(bullet->x, bullet->y, 20)) { score += 10; play_sample(data[BOOM_SPL].dat, 255, PAN(bullet->x), 1000, FALSE); /* delete the bullet that killed the alien */ bullet = delete_bullet(bullet); goto bullet_updated; } } bullet = bullet->next; bullet_updated:; } }
void delete_enemy(enemy * enemy) { int j; SDL_FreeSurface(enemy->sprite); for (j = 0; j < 10; j++) { delete_bullet(&(enemy->bullets[j])); } }
void delete_player(player * ship) { int i, j; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { SDL_FreeSurface(ship->sprites[i][j]); } } for (i = 0; i < 4; i++) { for (j = 0; j < 10; j++) { delete_bullet(&(ship->bullets[i][j])); } } }