source/ship.c
void ship_fire(struct Ship* ship) {
    /* index the bullet and find next one */
    struct ShipBullet* bullet = &(ship->bullets[ship->bullet_index]);
    ship->bullet_index++;
    if (ship->bullet_index >= SHIP_NUM_BULLTETS) {
        ship->bullet_index = 0;
    }

    /* place it under the ship */
    bullet->y = ship->y + 12;

    /* randomly fire from the left or right turret */
    if (rand() & 1) {
        bullet->x = ship->x - 3;
    } else {
        bullet->x = ship->x + 18;
    }
    bullet->alive = 1;
    play_sound(shipshoot_16K_mono, shipshoot_16K_mono_bytes, 16000, 'B');
}
/* have the ship fire a bullet */
have the ship fire a bullet
have the ship fire a bullet
void ship_fire(struct Ship* ship) {
    struct ShipBullet* bullet = &(ship->bullets[ship->bullet_index]);
    ship->bullet_index++;
    if (ship->bullet_index >= SHIP_NUM_BULLTETS) {
        ship->bullet_index = 0;
    }
    bullet->y = ship->y + 12;
    if (rand() & 1) {
        bullet->x = ship->x - 3;
    } else {
        bullet->x = ship->x + 18;
    }
    bullet->alive = 1;
    play_sound(shipshoot_16K_mono, shipshoot_16K_mono_bytes, 16000, 'B');
}
void ship_fire ( struct Ship * ship ) { struct ShipBullet * bullet = & ( ship -> bullets [ ship -> bullet_index ] ) ; ship -> bullet_index ++ ; if ( ship -> bullet_index >= SHIP_NUM_BULLTETS ) { ship -> bullet_index = 0 ; } bullet -> y = ship -> y + 12 ; if ( rand ( ) & 1 ) { bullet -> x = ship -> x - 3 ; } else { bullet -> x = ship -> x + 18 ; } bullet -> alive = 1 ; play_sound ( shipshoot_16K_mono , shipshoot_16K_mono_bytes , 16000 , ' ' ) ; }
have the ship fire a bullet
have the ship fire a bullet
/* index the bullet and find next one */ /* place it under the ship */ /* randomly fire from the left or right turret */