//
// PART14
// CREDITS
//

function part14() {
    this.vbl = 0 ;
    this.canvaspart;
    this.initdone = 0 ;

    var cvsg ;

    var hmd_my3d;
    var hmd_maptex3;
    var hmd_maptex4;
    var zoom2=0;
    var minimum=0.00;
    var mysin1=0;
    var myoldsin1=0;
    var mysin2=0;
    var myoldsin2=0;

    var vbl=0;
    var my3d_spr;

    var text_info1 = new Array();
    text_info1[0]="ASCII BY";
    text_info1[1]="SKIN";
    text_info1[2]="CODE BY";
    text_info1[3]="AYOROS";
    text_info1[4]="MUSIC BY";
    text_info1[5]="505";
    text_info1[6]="ASCII ART";

    var text_info2 = new Array();
    text_info2[0]="MUSIC BY";
    text_info2[1]="505";
    text_info2[2]="ALL DESIGN BY";
    text_info2[3]="PANDAFOX";
    text_info2[4]="SUPPORT";
    text_info2[5]="MARACUJA AND SINK";
    text_info2[6]="THE PACMAN";

    var text_info3 = new Array();
    text_info3[0]="CODE BY";
    text_info3[1]="AYOROS";
    text_info3[2]="AMIGA VERSION BY";
    text_info3[3]="STC";
    text_info3[4]="ART BY";
    text_info3[5]="PANDAFOX";
    text_info3[6]="CUBE WRITER";

    var text_info4 = new Array();
    text_info4[0]="CODE BY";
    text_info4[1]="AYOROS";
    text_info4[2]="OPTIMIZATION CODE BY";
    text_info4[3]="TOTORMAN";
    text_info4[4]="ART BY";
    text_info4[5]="PANDAFOX";
    text_info4[6]="3D TUNNEL";

    var text_info5 = new Array();
    text_info5[0]="CODE BY";
    text_info5[1]="AYOROS";
    text_info5[2]="ART BY";
    text_info5[3]="PANDAFOX";
    text_info5[4]="";
    text_info5[5]="";
    text_info5[6]="BESTIOLES";

    var text_info6 = new Array();
    text_info6[0]="CODE BY";
    text_info6[1]="AYOROS";
    text_info6[2]="OPTIMIZATION CODE BY";
    text_info6[3]="TOTORMAN";
    text_info6[4]="ART BY";
    text_info6[5]="PANDAFOX";
    text_info6[6]="FAKE LENS";

    var text_info7 = new Array();
    text_info7[0]="CODE BY";
    text_info7[1]="AYOROS";
    text_info7[2]="OPTIMIZATION CODE BY";
    text_info7[3]="TOTORMAN";
    text_info7[4]="ART BY";
    text_info7[5]="PANDAFOX";
    text_info7[6]="LANDSCAPES";

    var text_info8 = new Array();
    text_info8[0]="CODE BY";
    text_info8[1]="AYOROS";
    text_info8[2]="IDEA BY";
    text_info8[3]="ULM ON ATARI";
    text_info8[4]="ART BY";
    text_info8[5]="PANDAFOX";
    text_info8[6]="MAXI SCROLL";

    var text_info9 = new Array();
    text_info9[0]="CODE BY";
    text_info9[1]="AYOROS";
    text_info9[2]="ART BY";
    text_info9[3]="PANDAFOX";
    text_info9[4]="IDEA BY";
    text_info9[5]="ANARCHY";
    text_info9[6]="SPHERES";

    var text_info10 = new Array();
    text_info10[0]="CODE BY";
    text_info10[1]="AYOROS";
    text_info10[2]="OPTIMIZATION CODE BY";
    text_info10[3]="TOTORMAN";
    text_info10[4]="ART BY";
    text_info10[5]="PANDAFOX";
    text_info10[6]="LENS FLARE";

    var text_info11 = new Array();
    text_info11[0]="CODE BY";
    text_info11[1]="TOTORMAN";
    text_info11[2]="ART BY";
    text_info11[3]="PANDAFOX";
    text_info11[4]="IDEA BY";
    text_info11[5]="ANDROMEDA";
    text_info11[6]="EXPLOSION";

    var text_info12 = new Array();
    text_info12[0]="CODE BY";
    text_info12[1]="TOTORMAN";
    text_info12[2]="ART BY";
    text_info12[3]="PANDAFOX";
    text_info12[4]="IDEA BY";
    text_info12[5]="RED SECTOR INC.";
    text_info12[6]="RED SECTOR MAN";

    var text_info13 = new Array();
    text_info13[0]="CODE BY";
    text_info13[1]="TOTORMAN";
    text_info13[2]="ART BY";
    text_info13[3]="PANDAFOX";
    text_info13[4]="IDEA BY";
    text_info13[5]="SINK AND AYOROS";
    text_info13[6]="3D SCROLL";
    
    var text_info14 = new Array();
    text_info14[0]="MUSIC BY";
    text_info14[1]="SHOOTERS";
    text_info14[2]="ART BY";
    text_info14[3]="PANDAFOX";
    text_info14[4]="CODE BY";
    text_info14[5]="AYOROS, TOTORMAN";
    text_info14[6]="THIS END PART";

    var text_info15 = new Array();
    text_info15[0]="CODE BY";
    text_info15[1]="TOTORMAN";
    text_info15[2]="ART BY";
    text_info15[3]="PANDAFOX";
    text_info15[4]="REVISION LOGO BY";
    text_info15[5]="H2O";
    text_info15[6]="3D TEXTURE";

    var text_info16 = new Array();
    text_info16[0]="CODE BY";
    text_info16[1]="AYOROS";
    text_info16[2]="ART BY";
    text_info16[3]="PANDAFOX";
    text_info16[4]="PACMAN IDEA BY";
    text_info16[5]="MARACUJA";
    text_info16[6]="KALIDOSCOPE";

    var text_info17 = new Array();
    text_info17[0]="CODE BY";
    text_info17[1]="TOTORMAN";
    text_info17[2]="ART BY";
    text_info17[3]="PANDAFOX";
    text_info17[4]="        ";
    text_info17[5]="        ";
    text_info17[6]="3D GLENZ";

    var text_info18 = new Array();
    text_info18[0]="CODE BY";
    text_info18[1]="TOTORMAN";
    text_info18[2]="ART BY";
    text_info18[3]="PANDAFOX";
    text_info18[4]="        ";
    text_info18[5]="        ";
    text_info18[6]="PLASMA";
    
    var text_info19 = new Array();
    text_info19[0]="CODE BY";
    text_info19[1]="AYOROS";
    text_info19[2]="ART BY";
    text_info19[3]="PANDAFOX";
    text_info19[4]="      ";
    text_info19[5]="      ";
    text_info19[6]="THE MATCH";

    var text_info20 = new Array();
    text_info20[0]="CODE BY";
    text_info20[1]="AYOROS";
    text_info20[2]="ART BY";
    text_info20[3]="PANDAFOX";
    text_info20[4]="MUSIC BY";
    text_info20[5]="505";
    text_info20[6]="3D DOTS";
   
    var text_info21 = new Array();
    text_info21[0]="CODE BY";
    text_info21[1]="AYOROS";
    text_info21[2]="ART BY";
    text_info21[3]="PANDAFOX";
    text_info21[4]="IDEA BY";
    text_info21[5]="LEONARD";
    text_info21[6]="SPRITE RECORD";
   
    var text_info22 = new Array();
    text_info22[0]="CODE BY";
    text_info22[1]="AYOROS";
    text_info22[2]="ART BY";
    text_info22[3]="PANDAFOX";
    text_info22[4]="SEE ON";
    text_info22[5]="WIKIPEDIA";
    text_info22[6]="HARMONOGRAPH";

    var select_text_info=new Array();
    select_text_info=[text_info1,text_info2,text_info3,text_info6,text_info10,text_info15,text_info4,text_info5,text_info8,text_info20,text_info18,text_info7,text_info17,text_info11,text_info13,text_info12,text_info9,text_info21,text_info22,text_info16,text_info19,text_info14];

    var select_img_info = new Array();
    select_img_info=[ img_part[1],img_part[2],img_part[3],img_part[6],img_part[10],img_part[15],img_part[4],img_part[5],img_part[8],img_part[20],img_part[18],img_part[7],img_part[17],img_part[11],img_part[13],img_part[12],img_part[9],img_part[21],img_part[22],img_part[16],img_part[19],img_part[14] ];

    var text_greet1 = new Array();
    text_greet1[0]="FRAMEWORK BY";
    text_greet1[1]="NONAMENO";
    text_greet1[2]="SPECIAL THANKS TO";
    text_greet1[3]="505 - SKIN";
    text_greet1[4]="MEMBERS OF HEMOROIDS";
    text_greet1[5]="SINK - MARACUJA";
    text_greet1[6]="";
    text_greet1[7]="SHOOTERS-STC-ANGEL";
    text_greet1[8]="";
    text_greet1[9]="AYOROS-TOTORMAN";
    text_greet1[10]="";
    text_greet1[11]="PANDAFOX-KELLY X";

    var text_greet2 = new Array();
    text_greet2[0]="GREETINGS FLY TO";
    text_greet2[1]="SKID ROW - PARADOX";
    text_greet2[2]="";
    text_greet2[3]="DUNE - ZUUL - ULM";
    text_greet2[4]="";
    text_greet2[5]="RAHOW - ONSLAUGHT";
    text_greet2[6]="";
    text_greet2[7]="RAZOR - CHECKPOINT";
    text_greet2[8]="";
    text_greet2[9]="GENESIS PROJECT";
    text_greet2[10]="";
    text_greet2[11]="TRSI - DESIRE";

    var text_greet3 = new Array();
    text_greet3[0]="GREETINGS FLY TO";
    text_greet3[1]="SCOOPEX - NOEXTRA";
    text_greet3[2]="";
    text_greet3[3]="ANTHROX - DHS";
    text_greet3[4]="";
    text_greet3[5]="CASCADE - QUARTEX";
    text_greet3[6]="";
    text_greet3[7]="MYSTIC BYTES";
    text_greet3[8]="";
    text_greet3[9]="FAIRLIGHT - TSCC";
    text_greet3[10]="";
    text_greet3[11]="EQUINOX - IBB";

    var text_greet4 = new Array();
    text_greet4[0]="GREETINGS FLY TO";
    text_greet4[1]="POPSY TEAM";
    text_greet4[2]="";
    text_greet4[3]="MJJ PROD - X MEN";
    text_greet4[4]="";
    text_greet4[5]="ANARCHY - OXYRON";
    text_greet4[6]="";
    text_greet4[7]="BRAINWAVE - VISION";
    text_greet4[8]="";
    text_greet4[9]="BRAINSTORM - EKO";
    text_greet4[10]="";
    text_greet4[11]="ALL CODEF SCENE";

    var text_greet5 = new Array();
    text_greet5[0]  ="";
    text_greet5[1]  ="OLDSCHOOL";
    text_greet5[2]  ="";
    text_greet5[3]  ="NEVER DIE";
    text_greet5[4]  ="WWW.HEMOROIDS.EU";
    text_greet5[5]  ="";
    text_greet5[6]  ="";
    text_greet5[7]  ="THE END";
    text_greet5[8]  ="";
    text_greet5[9]  ="";
    text_greet5[10] ="";
    text_greet5[11] ="REVISION 2014";

    var select_text_info2=new Array();
    select_text_info2=[text_greet1,text_greet2,text_greet3,text_greet4,text_greet5];
    var all_finished = 0 ;

    var myobj_spr = new Array();
    var myobjvert_spr = new Array();
    myobjvert_spr=[];

    var image_part=select_img_info[0];
    var text_part=select_text_info[0];
    var increase = Math.PI / 100;
    var sy=0;
    var sx=0;
    var sz=0;
    var zx=0;
    var zy=0;
    var angle = 1;			 
    var zangle = 0;	
    var zoom=-1000;
    var xoom=0;
    var yoom=0;
    var time_part=0;
    var alpha_fade=0;
    var fade_end=0;
    var alphaimage_fade = 0 ;
    var fadeimage_end = 0 ;

    var part_cube=0;
    var mycanvas3;
    var mycanvas_tmp;
    var mycanvas3d;
    var i=0;
    var stop_part=0;
    var text_part2=select_text_info2[0];
    var to_next_part = 0 ;
    var time_part2=0;

    var mycanvas_stars;
    var mycanvas_texte;
    var mycanvas_white ;

    function particleRender(context) {
        var alpha = 0 ;
/*
        var tmp = Math.abs(context.currentTransform.a) ;

        if ( (tmp>0  ) && (tmp <=0.1) ) alpha = 0.05 ;
        if ( (tmp>0.1) && (tmp <=0.2) ) alpha = 0.2 ;
        if ( (tmp>0.2) && (tmp <=0.3) ) alpha = 0.4 ;
        if ( (tmp>0.3) && (tmp <=0.4) ) alpha = 0.5 ;
        if ( (tmp>0.4) && (tmp <=0.5) ) alpha = 0.6 ;
        if ( (tmp>0.5) && (tmp <=0.6) ) alpha = 0.7 ;
        if ( (tmp>0.6) && (tmp <=0.7) ) alpha = 0.8 ;
        if ( (tmp>0.7) && (tmp <=0.8) ) alpha = 0.9 ;
        if ( (tmp>0.8) && (tmp <=0.9) ) alpha = 0.95 ;
        if ( (tmp>0.9) && (tmp <=100) ) alpha = 1 ;

        context.globalAlpha = alpha; */
        context.drawImage( ball_part[0].img,0,0) ;
    }

    function init_stars(){
        my3d_spr=new codef3D(mycanvas_stars, 800, 70, 1, 6000 );
        my3d_spr.scene.fog = new THREE.FogExp2( 0x000000, 0.0009 );
        for (var i=0;i<600;i++){
            sx=(Math.floor((Math.random()*720))-360)*0.04;
            sy=(Math.floor((Math.random()*720))-360)*0.04;
            sz=(Math.floor((Math.random()*720))-360)*0.04;
            //myobjvert_spr.push({x:sx, y:sy, z: sz, img:0}); //color:0xffffff, size:1})	

                    var material = new THREE.ParticleCanvasMaterial ( { color : 0, program : particleRender } ) ;
                    var Particle = new THREE.Particle( material );
                    Particle.position.x = sx;
                    Particle.position.y = sy;
                    Particle.position.z = sz;
                    my3d_spr.group.add( Particle );

        }
        
//        my3d_spr.vectorball_img(myobjvert_spr, ball_part );
        my3d_spr.group.scale.x=my3d_spr.group.scale.y=my3d_spr.group.scale.z=100;
    }


    function do_greetings(dest,text_part2){
        if ( (time_part2 >= 0) && (time_part2 < 300) ) {
              if (time_part2==0) {
                mycanvas_tmp.clear();

                write_line(myfont_credits,mycanvas_tmp,0,0,text_part2[0],1,0) ;
                write_line(myfont_credits2,mycanvas_tmp,0,20,text_part2[1],1,18) ;
                write_line(myfont_credits,mycanvas_tmp,0,100,text_part2[2],1,0) ;
                write_line(myfont_credits2,mycanvas_tmp,0,120,text_part2[3],1,18) ;
                write_line(myfont_credits,mycanvas_tmp,0,200,text_part2[4],1,0) ;
                write_line(myfont_credits2,mycanvas_tmp,0,220,text_part2[5],1,18) ;
                write_line(myfont_credits,mycanvas_tmp,0,300,text_part2[6],1,0) ;
                write_line(myfont_credits2,mycanvas_tmp,0,320,text_part2[7],1,18) ;
                write_line(myfont_credits,mycanvas_tmp,0,400,text_part2[8],1,0) ;
                write_line(myfont_credits2,mycanvas_tmp,0,420,text_part2[9],1,18) ;
                write_line(myfont_credits,mycanvas_tmp,0,500,text_part2[10],1,0) ;
                write_line(myfont_credits2,mycanvas_tmp,0,520,text_part2[11],1,18) ;  
                alpha_fade = 0 ;
                fade_end = 0 ;
              }
              
              mycanvas_tmp.draw(dest,0,0,alpha_fade);
              if ( fade_end<=50 ) { alpha_fade += 0.02; }
              if ( (fade_end>=250 ) && (fade_end<300) ) { alpha_fade -= 0.02 ; }
              fade_end++ ;
        }
     
        time_part2 = ( time_part2 +1) % 300 ;
        if (time_part2 == 0) to_next_part =1 ;
    }

    function do_all_finished(dest,text_part2){
        mycanvas_tmp.clear() ;
        write_line(myfont_credits,mycanvas_tmp,0,0,text_part2[0],1,0) ;
        write_line(myfont_credits2,mycanvas_tmp,0,20,text_part2[1],1,18) ;
        write_line(myfont_credits,mycanvas_tmp,0,100,text_part2[2],1,0) ;
        write_line(myfont_credits2,mycanvas_tmp,0,120,text_part2[3],1,18) ;
        write_line(myfont_credits,mycanvas_tmp,0,200,text_part2[4],1,0) ;
        write_line(myfont_credits2,mycanvas_tmp,0,220,text_part2[5],1,18) ;
        write_line(myfont_credits,mycanvas_tmp,0,300,text_part2[6],1,0) ;
        write_line(myfont_credits2,mycanvas_tmp,0,320,text_part2[7],1,18) ;
        write_line(myfont_credits,mycanvas_tmp,0,400,text_part2[8],1,0) ;
        write_line(myfont_credits2,mycanvas_tmp,0,420,text_part2[9],1,18) ;
        write_line(myfont_credits,mycanvas_tmp,0,500,text_part2[10],1,0) ;
        write_line(myfont_credits2,mycanvas_tmp,0,520,text_part2[11],1,18) ;  
        mycanvas_tmp.draw(dest,0,0,1);
    }

    function stars(){
        my3d_spr.group.rotation.x+=0.010;
        my3d_spr.group.rotation.y+=0.003;
        my3d_spr.group.rotation.z+=0.002;

        for (var i=0;i<600;i++){
            my3d_spr.group.children[i].position.x -= 0.08;
            if (my3d_spr.group.children[i].position.x < -16){
                my3d_spr.group.children[i].position.x = 16;
            }
        }

        //mycanvas.contex.globalCompositeOperation='lighter';	
        my3d_spr.draw();
        //mycanvas.contex.globalCompositeOperation='source-over';	
    }

    function do3d(dest,image_part,text_part){
        mycanvas3d.clear();

        hmd_my3d.scene.children[2].rotation.x += 0.02;
        hmd_my3d.scene.children[2].rotation.y += 0.05;
        hmd_my3d.scene.children[2].rotation.z += 0.01;

        hmd_my3d.scene.children[3].rotation.x += 0.02;
        hmd_my3d.scene.children[3].rotation.y += 0.05;
        hmd_my3d.scene.children[3].rotation.z += 0.01;

        // Planes position
        hmd_my3d.scene.children[2].position.z = zoom;
        hmd_my3d.scene.children[3].position.z = zoom;
        hmd_my3d.scene.children[2].position.x = xoom;
        hmd_my3d.scene.children[3].position.x = xoom;
        hmd_my3d.scene.children[2].position.y = yoom;
        hmd_my3d.scene.children[3].position.y = yoom;

        if   (time_part <= 150)                       { zoom += 8   ;}
        if ( (time_part >  150) && (time_part < 200) ){ zoom -= 4   ;}
        if ( (time_part >= 200) && (time_part < 220) ){ xoom -= 1.2 ;}
        if ( (time_part >= 200) && (time_part < 216) ){ yoom += 1.5 ;}
        if ( (time_part >= 200) && (time_part < 216) ){ zoom -= 0.5 ;}
        if ( (time_part >= 216) && (time_part < 236) ){ xoom += 1.2 ;}

        if ( (time_part >= 100) && ( time_part < 400 ) ) {
            if (time_part == 100) {
                mycanvas_tmp.clear();
                write_line(myfont_credits,mycanvas_tmp,0,300,text_part[0],1,0) ;
                write_line(myfont_credits2,mycanvas_tmp,0,320,text_part[1],1,18) ;
                write_line(myfont_credits,mycanvas_tmp,0,400,text_part[2],1,0) ;
                write_line(myfont_credits2,mycanvas_tmp,0,420,text_part[3],1,18) ;
                write_line(myfont_credits,mycanvas_tmp,0,500,text_part[4],1,0) ;
                write_line(myfont_credits2,mycanvas_tmp,0,520,text_part[5],1,18) ;
                fade_end = 0 ;
                alpha_fade = 0 ;
            }
           mycanvas_tmp.draw(dest,0,0,alpha_fade);

            if ( fade_end < 50 ) { alpha_fade = alpha_fade + 0.02 ; }
            if ( (fade_end >= 250) && (fade_end < 300) ) { alpha_fade = Math.max(alpha_fade - 0.02,0); }
            if ( fade_end > 299 ) { fade_end = 0 ; }
            fade_end++;
        }

        if ( (time_part >= 400 ) && ( time_part < 416 ) ) { yoom -= 1.5; }
        if ( (time_part >= 416 ) && ( time_part < 446 ) ) { zoom += 6  ; }
        if ( (time_part >= 446 ) && ( time_part < 500 ) ) { zoom -= 6  ; }
        if   (time_part >= 550 )                          { zoom = -1000 ;
                                                            xoom = 0 ; 
                                                            yoom = 0 ; 
                                                            time_part = 0 ; 
                                                            to_next_part = 1 ;
                                                            alphaimage_fade = 0 ;
                                                            }

        if ( (time_part>50) && ( time_part<=100 )) { alphaimage_fade += 0.02; }
        if ( (time_part>500 ) && (alphaimage_fade>0.02) ) { alphaimage_fade -= 0.02 ; }

        image_part.draw(mycanvas3);

        hmd_maptex3.needsUpdate=true;
        hmd_maptex4.needsUpdate=true;

        hmd_my3d.draw();

        cvsg.clear() ;
        if (text_part[6] != "") VerticalDraw(cvsg,text_part[6],myfont_credits2,8,8) ;

        if (time_part<dest.height/2) {
            cvsg.draw(dest,0,dest.height - time_part*2,alphaimage_fade) ;
        } else {
            if (time_part<750) cvsg.draw(dest,0,0,alpha_fade) ;
        }

        time_part++;
    }

    function VerticalDraw(dest,s,font,x,inc) {
        var starty = dest.height /2 - s.length * (font.tileh+inc) /2 ;
        for (var i=0; i<s.length; i++) {
            font.drawTile( dest, get_letter(s[i]), x , starty + i*(font.tileh+inc)  , 1 );
        }
    }

    function font_space(c,spa) {
        var result = 0 ;
        var choice=spa;
        switch(c)
        {
        case '!' : result = 12 ; break;
        case '(' : result = 12 ; break;
        case ')' : result = 12 ; break;
        case '@' : result = 12 ; break;
        case '"' : result = 16 ; break;
        case '\'': result = 8 ; break;
        case '/': result = 16 ; break;
        case '<': result = 20 ; break;
        case ',' : result = 8 ; break;
        case '.' : if (all_finished ==1) { result = 16 ; } else result = 8 ;  break;
        case ':' : result = 8; break; 
     
        default: result = (20 + choice) ; break;
        }  

        return result;
    }

    function line_width(s,spa) {
        var result = 0 ;
        for (var i=0, c; c=s[i]; i++)
            result += font_space(c,spa) ;
        return result ;
    }

    function get_letter(c) {
        return ( (c.charCodeAt(0)-32) );
    }

    function write_line(font, dest,x,y,s,alpha,spa) {
        var decale = 0 ;
       
        for (var j=0, c; c=s[j]; j++) {
            font.drawTile( dest, get_letter(c), 720/2 - line_width(s,spa)/2 + x+decale  , y  , alpha );
            decale += font_space(c,spa) ;
        }
    }

    this.init = function(dest) {
        mycanvas_white = new canvas(dest.width, dest.height) ;
        mycanvas_white.fill("#000000") ;

        mycanvas_texte=new canvas(720,576);

        mycanvas_tmp=new canvas(720,576);
        mycanvas3=new canvas(302,204);
        mycanvas3d=new canvas(720,576);
        mycanvas_stars=new canvas(720,576);

        hmd_maptex3 = new Texture(mycanvas3.canvas);
        hmd_maptex4 = new Texture(mycanvas3.canvas);

        hmd_my3d=new codef3D(mycanvas3d, 200, 25, 1,1000 );

        var plane = new THREE.PlaneGeometry(50, 30, 5, 5 );
        var materialReflection = new THREE.MeshBasicMaterial( { map: hmd_maptex3, overdraw: true } );
        mesh = new THREE.Mesh( plane, materialReflection );
        hmd_my3d.scene.add(mesh) ;

        var materialReflectionrev = new THREE.MeshBasicMaterial( { map: hmd_maptex4, overdraw: true } );
        mesh = new THREE.Mesh( plane, materialReflectionrev );
        mesh.rotation.z = Math.PI ;
        mesh.scale.z = -1 ;
        mesh.scale.x = -1 ;
        mesh.scale.y = -1 ;
        hmd_my3d.scene.add(mesh) ;

        init_stars();

        players4 = new Audio();
        players4.autobuffer=true;
        players4.loop = true;
        players4.src = (basepathsnd + 'oldernity.ogg');
        players4.autoplay=true; 

        myfont_credits.initTile(16,16,32);
        myfont_credits2.initTile(32,32,32);
        cvsg = new canvas(48,576) ;

        this.initdone = 1 ;
        end_total=1;
    }

    this.render = function(dest) {
        if (this.initdone == 0) { this.canvaspart = new canvas(720,576) ; this.init(dest) ; }

        this.canvaspart.fill('#161b1e');

        mycanvas_stars.clear();
        stars();
        mycanvas_stars.draw(this.canvaspart,0,0);

        if (this.vbl > 200) {
            if (all_finished == 1) {
                do_all_finished( this.canvaspart,select_text_info2[select_text_info2.length-1]);
            } else {
                if (stop_part==0){
                    if (to_next_part == 1){
                        to_next_part = 0 ;
                        i++;
                        if (i==select_text_info2.length-1) { i=0; stop_part=1; }

                        text_part2 = select_text_info2[i];
                    }
                    if (stop_part == 0) do_greetings( this.canvaspart,text_part2);
                }
                else {
                    if (to_next_part == 1){
                        to_next_part = 0 ;
                        i++;
                        if (i==select_text_info.length) { i=0; stop_part=0; all_finished = 1 ;}
                        image_part = select_img_info[i];
                        text_part = select_text_info[i];
                    }
                    if (i>-1) {
                        do3d( this.canvaspart,image_part,text_part);
                        mycanvas3d.draw(this.canvaspart,0,0,alphaimage_fade); 
                    }
                }
            }
        }
        this.canvaspart.draw(dest,0,0);
   
        if (this.vbl<200) mycanvas_white.draw(dest,0,0,1-this.vbl/200);

        this.vbl++ ;
    }

    return this;
}

///////////////
//END PART14//
/////////////