source/ship.c
int ship_update(struct Ship* ship, int scroll, struct Rover* rover) {
    if (!ship->visible) {
        /* update hidden frames */
        ship->frames_hidden++;

        /* check if time to show up */
        if (ship->frames_hidden >= SHIP_HIDDEN_FRAMES) {
            ship->visible = 1;
            ship->fire_countdown = SHIP_FIRE_DELAY;
        } else {
            return 0;
        }
    }

    /* check if this is a skip frame */
    ship->update_frames++;
    if (ship->update_frames >= SHIP_FRAME_SKIP) {
        ship->update_frames = 0;
    }
    if (ship->update_frames > 0) {
        return 0;
    }

    /* check if it's time to fire */
    ship->fire_countdown--;
    if (ship->fire_countdown == 0) {
        /* fire the bullet */
        ship_fire(ship);

        /* reset the counter */
        ship->fire_countdown = SHIP_FIRE_DELAY;
    }

    /* update the bullets */
    for (int i = 0; i < SHIP_NUM_BULLTETS; i++) {
        if (ship->bullets[i].alive) {
            ship->bullets[i].y += SHIP_BULLET_SPEED;
            sprite_position(ship->bullets[i].bullet_sprite, ship->bullets[i].x, ship->bullets[i].y); 

            /* check if it hit the rover */
            if ((ship->bullets[i].y - 4) >= (rover->y >> VERT_SHIFT_AMOUNT)) {
                if (ship->bullets[i].x > (rover->x + 32)) {
                    /* no collision */
                }
                else if ((ship->bullets[i].x + 8) < rover->x) {
                    /* no collision */
                } else {
                    /* BOOM */
                    return 1;
                }
            }

            /* check if the bullet hit the ground */
            if (ship->bullets[i].y > 140) {
                ship->bullets[i].x = -100;
                ship->bullets[i].y = -100;
                sprite_position(ship->bullets[i].bullet_sprite, ship->bullets[i].x, ship->bullets[i].y);
                ship->bullets[i].alive = 0;
            }
        }
    }


    /* update the ship position based on the paths */
    ship->x += ship_x_directions[ship->movement_counter];
    ship->y += ship_y_directions[ship->movement_counter];

    /* update the counter */
    ship->movement_counter++;
    if (ship->movement_counter >= SHIP_PATH_SIZE) {
        ship->movement_counter = SHIP_LOOP_START;
    }

    /* position the sprite */
    sprite_position(ship->sprite, ship->x, ship->y);
    return 0;
}
/* flip the wheel animation in the ship and update it's position
 * relative to the scrolling ground */
flip the wheel animation in the ship and update it's position
relative to the scrolling ground
flip the wheel animation in the ship and update it ' s position relative to the scrolling ground
int ship_update(struct Ship* ship, int scroll, struct Rover* rover) {
    if (!ship->visible) {
        ship->frames_hidden++;
        if (ship->frames_hidden >= SHIP_HIDDEN_FRAMES) {
            ship->visible = 1;
            ship->fire_countdown = SHIP_FIRE_DELAY;
        } else {
            return 0;
        }
    }
    ship->update_frames++;
    if (ship->update_frames >= SHIP_FRAME_SKIP) {
        ship->update_frames = 0;
    }
    if (ship->update_frames > 0) {
        return 0;
    }
    ship->fire_countdown--;
    if (ship->fire_countdown == 0) {
        ship_fire(ship);
        ship->fire_countdown = SHIP_FIRE_DELAY;
    }
    for (int i = 0; i < SHIP_NUM_BULLTETS; i++) {
        if (ship->bullets[i].alive) {
            ship->bullets[i].y += SHIP_BULLET_SPEED;
            sprite_position(ship->bullets[i].bullet_sprite, ship->bullets[i].x, ship->bullets[i].y); 
            if ((ship->bullets[i].y - 4) >= (rover->y >> VERT_SHIFT_AMOUNT)) {
                if (ship->bullets[i].x > (rover->x + 32)) {
                }
                else if ((ship->bullets[i].x + 8) < rover->x) {
                } else {
                    return 1;
                }
            }
            if (ship->bullets[i].y > 140) {
                ship->bullets[i].x = -100;
                ship->bullets[i].y = -100;
                sprite_position(ship->bullets[i].bullet_sprite, ship->bullets[i].x, ship->bullets[i].y);
                ship->bullets[i].alive = 0;
            }
        }
    }
    ship->x += ship_x_directions[ship->movement_counter];
    ship->y += ship_y_directions[ship->movement_counter];
    ship->movement_counter++;
    if (ship->movement_counter >= SHIP_PATH_SIZE) {
        ship->movement_counter = SHIP_LOOP_START;
    }
    sprite_position(ship->sprite, ship->x, ship->y);
    return 0;
}
int ship_update ( struct Ship * ship , int scroll , struct Rover * rover ) { if ( ! ship -> visible ) { ship -> frames_hidden ++ ; if ( ship -> frames_hidden >= SHIP_HIDDEN_FRAMES ) { ship -> visible = 1 ; ship -> fire_countdown = SHIP_FIRE_DELAY ; } else { return 0 ; } } ship -> update_frames ++ ; if ( ship -> update_frames >= SHIP_FRAME_SKIP ) { ship -> update_frames = 0 ; } if ( ship -> update_frames > 0 ) { return 0 ; } ship -> fire_countdown -- ; if ( ship -> fire_countdown == 0 ) { ship_fire ( ship ) ; ship -> fire_countdown = SHIP_FIRE_DELAY ; } for ( int i = 0 ; i < SHIP_NUM_BULLTETS ; i ++ ) { if ( ship -> bullets [ i ] . alive ) { ship -> bullets [ i ] . y += SHIP_BULLET_SPEED ; sprite_position ( ship -> bullets [ i ] . bullet_sprite , ship -> bullets [ i ] . x , ship -> bullets [ i ] . y ) ; if ( ( ship -> bullets [ i ] . y - 4 ) >= ( rover -> y >> VERT_SHIFT_AMOUNT ) ) { if ( ship -> bullets [ i ] . x > ( rover -> x + 32 ) ) { } else if ( ( ship -> bullets [ i ] . x + 8 ) < rover -> x ) { } else { return 1 ; } } if ( ship -> bullets [ i ] . y > 140 ) { ship -> bullets [ i ] . x = -100 ; ship -> bullets [ i ] . y = -100 ; sprite_position ( ship -> bullets [ i ] . bullet_sprite , ship -> bullets [ i ] . x , ship -> bullets [ i ] . y ) ; ship -> bullets [ i ] . alive = 0 ; } } } ship -> x += ship_x_directions [ ship -> movement_counter ] ; ship -> y += ship_y_directions [ ship -> movement_counter ] ; ship -> movement_counter ++ ; if ( ship -> movement_counter >= SHIP_PATH_SIZE ) { ship -> movement_counter = SHIP_LOOP_START ; } sprite_position ( ship -> sprite , ship -> x , ship -> y ) ; return 0 ; }
flip the wheel animation in the ship and update it's position
 relative to the scrolling ground
flip the wheel animation in the ship and update it ' s position relative to the scrolling ground
/* update hidden frames */ /* check if time to show up */ /* check if this is a skip frame */ /* check if it's time to fire */ /* fire the bullet */ /* reset the counter */ /* update the bullets */ /* check if it hit the rover */ /* no collision */ /* no collision */ /* BOOM */ /* check if the bullet hit the ground */ /* update the ship position based on the paths */ /* update the counter */ /* position the sprite */