// External custom code to be run from a script


void tonel_falling (void) {
    int n;
    for(n = 0; n < 10; n ++) {
        draw_coloured_tile(27, 8 + n, 14); // pinta tonel
        peta_el_beeper (5);
        sp_UpdateNow ();
        draw_coloured_tile(27, 8 + n, 0); // borrar tonel para el siguiente frame
    }
}

void do_extern_action (unsigned char n_action) {
    switch (n_action){
        case 0:
        case 2:
        case 4:
            draw_coloured_tile((20 - n_action) ,21 , 23 - (n_action/2) );
	        print_str (9,  2, 79, " BRAVO JUSTIN! ", TRUE);
            player.score ++;
            break;
        case 10: // animacion del tonel cayendo
            tonel_falling();
        case 15:
            player.score ++;
            break;

        case 11: // puerta secreta, poniendo boton especial
            draw_coloured_tile(5, 16, 17); 
            draw_coloured_tile(6, 16, 0); 
            break;

        case 38: // puerta secreta, poniendo boton especial OFF
            draw_coloured_tile(3, 8, 17); 
            draw_coloured_tile(4, 8, 0); 
            break;
            
        case 39: // puerta secreta, poniendo boton especial ON
            draw_coloured_tile(2, 8, 17); 
            draw_coloured_tile(1, 8, 5);
            break;
    }
}
