source/rover.c
void rover_crash(struct Rover* rover) {
    /* play the sound effect on channel B */
    play_sound(crash_16K_mono, crash_16K_mono_bytes, 16000, 'B');

    /* move down a bit */
    rover->y += (4 << VERT_SHIFT_AMOUNT);

    /* keep track of the wheel postions */
    int wheelx[3], wheely[3];
    for (int i = 0; i < 3; i++) {
        wheelx[i] = rover->x + WHEEL_SPACING * i;
        wheely[i] = (rover->wheel_height[i] >> VERT_SHIFT_AMOUNT) + WHEEL_DROP;
    }

    /* hacky, but looks alright I guess
     * this code fakes a gravity like up then falling animation for the wheels */
    for (int i = 0; i < 100; i++) {
        int amt;
        if (i < 10) {
            amt = -2;
        } else if (i < 20) {
            amt = -1;
        } else if (i < 30) {
           if (i & 1)
               amt = -1;
           else
               amt = 0;
        } else if (i < 40) {
            amt = 0;
        } else if (i < 60) {
            amt = 1;
        } else {
            amt = 2;
        }
        /* move the wheels some */
        if (i & 1) {
            wheelx[0]--;
            wheelx[2]++;
        }
        wheely[0] += amt;
        wheely[1] += amt;
        wheely[2] += amt;

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

        /* wait for vertical refresh again */
        wait_vblank();

        /* update all sprites on screen */
        sprite_update_all();

        /* delay for a little bit */
        delay(750);
    }
}
/* crash the rover when it has been destroyed */
crash the rover when it has been destroyed
crash the rover when it has been destroyed
void rover_crash(struct Rover* rover) {
    play_sound(crash_16K_mono, crash_16K_mono_bytes, 16000, 'B');
    rover->y += (4 << VERT_SHIFT_AMOUNT);
    int wheelx[3], wheely[3];
    for (int i = 0; i < 3; i++) {
        wheelx[i] = rover->x + WHEEL_SPACING * i;
        wheely[i] = (rover->wheel_height[i] >> VERT_SHIFT_AMOUNT) + WHEEL_DROP;
    }
    for (int i = 0; i < 100; i++) {
        int amt;
        if (i < 10) {
            amt = -2;
        } else if (i < 20) {
            amt = -1;
        } else if (i < 30) {
           if (i & 1)
               amt = -1;
           else
               amt = 0;
        } else if (i < 40) {
            amt = 0;
        } else if (i < 60) {
            amt = 1;
        } else {
            amt = 2;
        }
        if (i & 1) {
            wheelx[0]--;
            wheelx[2]++;
        }
        wheely[0] += amt;
        wheely[1] += amt;
        wheely[2] += amt;
        sprite_position(rover->body, rover->x, rover->y >> VERT_SHIFT_AMOUNT);
        for (int i = 0; i < NUM_WHEELS; i++) {
            sprite_position(rover->wheels[i], wheelx[i], wheely[i]);
        }
        wait_vblank();
        sprite_update_all();
        delay(750);
    }
}
void rover_crash ( struct Rover * rover ) { play_sound ( crash_16K_mono , crash_16K_mono_bytes , 16000 , ' ' ) ; rover -> y += ( 4 << VERT_SHIFT_AMOUNT ) ; int wheelx [ 3 ] , wheely [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) { wheelx [ i ] = rover -> x + WHEEL_SPACING * i ; wheely [ i ] = ( rover -> wheel_height [ i ] >> VERT_SHIFT_AMOUNT ) + WHEEL_DROP ; } for ( int i = 0 ; i < 100 ; i ++ ) { int amt ; if ( i < 10 ) { amt = -2 ; } else if ( i < 20 ) { amt = -1 ; } else if ( i < 30 ) { if ( i & 1 ) amt = -1 ; else amt = 0 ; } else if ( i < 40 ) { amt = 0 ; } else if ( i < 60 ) { amt = 1 ; } else { amt = 2 ; } if ( i & 1 ) { wheelx [ 0 ] -- ; wheelx [ 2 ] ++ ; } wheely [ 0 ] += amt ; wheely [ 1 ] += amt ; wheely [ 2 ] += amt ; sprite_position ( rover -> body , rover -> x , rover -> y >> VERT_SHIFT_AMOUNT ) ; for ( int i = 0 ; i < NUM_WHEELS ; i ++ ) { sprite_position ( rover -> wheels [ i ] , wheelx [ i ] , wheely [ i ] ) ; } wait_vblank ( ) ; sprite_update_all ( ) ; delay ( 750 ) ; } }
crash the rover when it has been destroyed
crash the rover when it has been destroyed
/* play the sound effect on channel B */ /* move down a bit */ /* keep track of the wheel postions */ /* hacky, but looks alright I guess
     * this code fakes a gravity like up then falling animation for the wheels */ /* move the wheels some */ /* set the position */ /* wait for vertical refresh again */ /* update all sprites on screen */ /* delay for a little bit */