source/rover.c
void rover_update(struct Rover* rover, struct Ship* ship, int scroll, int* bonus) {
    /* flip the animation, and calculate the rover elevation */
    rover_flip(rover);

    /* update position based on jumping */
    if (rover->jumping) {
        /* adjust for jumping */
        rover->y += rover->dy;

        /* set wheels to the same height (shifted down a scoche) */
        for (int i = 0; i < NUM_WHEELS; i++) {
            rover->wheel_height[i] = rover->y + 512;
        }

        /* decelerate */
        rover->dy += GRAVITY;

    } else {
        /* else position based on the ground */
        rover_elevate(rover, scroll); 
    }

    /* if we are at ground level again, stop jumping */
    if (rover->jumping && (rover->y >> VERT_SHIFT_AMOUNT) > GROUND_HEIGHT) {
        rover->jumping = 0;
    }

    /* position the sprite */
    sprite_position(rover->body, rover->x, rover->y >> VERT_SHIFT_AMOUNT);
    for (int i = 0; i < NUM_WHEELS; i++) {
        sprite_position(rover->wheels[i], rover->x + WHEEL_SPACING * i,
                (rover->wheel_height[i] >> VERT_SHIFT_AMOUNT) + WHEEL_DROP);
    }

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

            /* check if it hit the ship */
            if (rover->bullets[i].y < ship->y) {
                if (rover->bullets[i].x > (ship->x + 32)) {
                    /* no collision */
                }
                else if ((rover->bullets[i].x + 8) < ship->x) {
                    /* no collision */
                } else {
                    ship_kill(ship);
                    *bonus += 100;
                }
            }

            /* check if the bullet went off screen */
            if (rover->bullets[i].y < 0) {
                rover->bullets[i].x = -100;
                rover->bullets[i].y = -100;
                sprite_position(rover->bullets[i].bullet_sprite, rover->bullets[i].x, rover->bullets[i].y);
                rover->bullets[i].alive = 0;
            }
        }
    }
}
/* flip the wheel animation in the rover and update it's position
 * relative to the scrolling ground */
flip the wheel animation in the rover and update it's position
relative to the scrolling ground
flip the wheel animation in the rover and update it ' s position relative to the scrolling ground
void rover_update(struct Rover* rover, struct Ship* ship, int scroll, int* bonus) {
    rover_flip(rover);
    if (rover->jumping) {
        rover->y += rover->dy;
        for (int i = 0; i < NUM_WHEELS; i++) {
            rover->wheel_height[i] = rover->y + 512;
        }
        rover->dy += GRAVITY;
    } else {
        rover_elevate(rover, scroll); 
    }
    if (rover->jumping && (rover->y >> VERT_SHIFT_AMOUNT) > GROUND_HEIGHT) {
        rover->jumping = 0;
    }
    sprite_position(rover->body, rover->x, rover->y >> VERT_SHIFT_AMOUNT);
    for (int i = 0; i < NUM_WHEELS; i++) {
        sprite_position(rover->wheels[i], rover->x + WHEEL_SPACING * i,
                (rover->wheel_height[i] >> VERT_SHIFT_AMOUNT) + WHEEL_DROP);
    }
    for (int i = 0; i < ROVER_NUM_BULLTETS; i++) {
        if (rover->bullets[i].alive) {
            rover->bullets[i].y -= ROVER_BULLET_SPEED;
            sprite_position(rover->bullets[i].bullet_sprite, rover->bullets[i].x, rover->bullets[i].y); 
            if (rover->bullets[i].y < ship->y) {
                if (rover->bullets[i].x > (ship->x + 32)) {
                }
                else if ((rover->bullets[i].x + 8) < ship->x) {
                } else {
                    ship_kill(ship);
                    *bonus += 100;
                }
            }
            if (rover->bullets[i].y < 0) {
                rover->bullets[i].x = -100;
                rover->bullets[i].y = -100;
                sprite_position(rover->bullets[i].bullet_sprite, rover->bullets[i].x, rover->bullets[i].y);
                rover->bullets[i].alive = 0;
            }
        }
    }
}
void rover_update ( struct Rover * rover , struct Ship * ship , int scroll , int * bonus ) { rover_flip ( rover ) ; if ( rover -> jumping ) { rover -> y += rover -> dy ; for ( int i = 0 ; i < NUM_WHEELS ; i ++ ) { rover -> wheel_height [ i ] = rover -> y + 512 ; } rover -> dy += GRAVITY ; } else { rover_elevate ( rover , scroll ) ; } if ( rover -> jumping && ( rover -> y >> VERT_SHIFT_AMOUNT ) > GROUND_HEIGHT ) { rover -> jumping = 0 ; } sprite_position ( rover -> body , rover -> x , rover -> y >> VERT_SHIFT_AMOUNT ) ; for ( int i = 0 ; i < NUM_WHEELS ; i ++ ) { sprite_position ( rover -> wheels [ i ] , rover -> x + WHEEL_SPACING * i , ( rover -> wheel_height [ i ] >> VERT_SHIFT_AMOUNT ) + WHEEL_DROP ) ; } for ( int i = 0 ; i < ROVER_NUM_BULLTETS ; i ++ ) { if ( rover -> bullets [ i ] . alive ) { rover -> bullets [ i ] . y -= ROVER_BULLET_SPEED ; sprite_position ( rover -> bullets [ i ] . bullet_sprite , rover -> bullets [ i ] . x , rover -> bullets [ i ] . y ) ; if ( rover -> bullets [ i ] . y < ship -> y ) { if ( rover -> bullets [ i ] . x > ( ship -> x + 32 ) ) { } else if ( ( rover -> bullets [ i ] . x + 8 ) < ship -> x ) { } else { ship_kill ( ship ) ; * bonus += 100 ; } } if ( rover -> bullets [ i ] . y < 0 ) { rover -> bullets [ i ] . x = -100 ; rover -> bullets [ i ] . y = -100 ; sprite_position ( rover -> bullets [ i ] . bullet_sprite , rover -> bullets [ i ] . x , rover -> bullets [ i ] . y ) ; rover -> bullets [ i ] . alive = 0 ; } } } }
flip the wheel animation in the rover and update it's position
 relative to the scrolling ground
flip the wheel animation in the rover and update it ' s position relative to the scrolling ground
/* flip the animation, and calculate the rover elevation */ /* update position based on jumping */ /* adjust for jumping */ /* set wheels to the same height (shifted down a scoche) */ /* decelerate */ /* else position based on the ground */ /* if we are at ground level again, stop jumping */ /* position the sprite */ /* update the bullets */ /* check if it hit the ship */ /* no collision */ /* no collision */ /* check if the bullet went off screen */