//////////////////////
// Mutli Scroll ULM//
//Code By Ayoros  //
///////////////////
function part8() {
    this.vbl = 0 ;
    this.canvaspart;
    this.initdone = 0 ;

var pos_sprite = new Array();
pos_sprite[0]=0.2*1;
pos_sprite[1]=0.2*2;
pos_sprite[2]=0.2*3;
pos_sprite[3]=0.2*4;
pos_sprite[4]=0.2*5;
pos_sprite[5]=0.2*6;
pos_sprite[6]=0.2*7;
pos_sprite[7]=0.2*8;
pos_sprite[8]=0.2*9;
var ulm_canvas;
var mycanvas_ulm;
var ulmscrolltext;
var ulmscrollsin=[];
var ulmscrollsincount=0;
var distadd=0;
//speed, size, distapart, time

var distformations=[[0.05,30,0.05,10],[0.1,12,0.1,20],[0.2,5,0.2,70],[0.3,10,0.25,30],[0.1,20,0.1,30],[0.01,1,0.02,20]]; //,[0.08,40,0.1,40]] //,[0.03,100,0.06,200],[0.07,100,0.05,50]];
var disttimer=0;
var distform=0;
var distspeed=0.05;
var distsize=0;
var distgap=0;
var disttimer2=0;
var disttimer3=0;




var vbl_ulm=0;
function do_sprite(dest){
 for (nbre_sprite=0; nbre_sprite < 9; nbre_sprite++)
	{
		pos_sprite[nbre_sprite] += 0.03;
		hmd_sprite[nbre_sprite].draw(dest, 300 + 250*Math.sin(pos_sprite[nbre_sprite]), 200 + 170*Math.cos(pos_sprite[nbre_sprite]*2) );
	}
}

    this.init = function() {
        ulm_canvas=new canvas(700,38);
        mycanvas_ulm=new canvas(700,442);
        font_ulm.initTile(38,38,32);
        ulmscrolltext = new scrolltext_horizontal();
       	ulmscrolltext.scrtxt="YEEAAAHHHH.GREETINGS TO ALL OUR FRIENDS IN THE WORLD...OLDSKOOL WILL NEVER DIE...WHEN PREPARATION H IS NOT ENOUGH....                            ";
        ulmscrolltext.init(ulm_canvas,font_ulm,4);
        for(var i=0;i<700*2;i++){
          ulmscrollsin[i]=50*Math.sin(i*0.05);	
        } 		
  
        mycanvas_ulm.initTile(800,2);
        fond_scroll.setmidhandle();
        hmd_sprite[0].setmidhandle();
        hmd_sprite[1].setmidhandle();
        hmd_sprite[2].setmidhandle();
        hmd_sprite[3].setmidhandle();
        hmd_sprite[4].setmidhandle();
        hmd_sprite[5].setmidhandle();
        hmd_sprite[6].setmidhandle();
        hmd_sprite[7].setmidhandle();
        hmd_sprite[8].setmidhandle();

        this.initdone = 1 ;
     }

    this.render = function(dest) {
        if (this.initdone == 0) { this.canvaspart = new canvas(600,400) ; this.init() ; }
        
        this.canvaspart.clear();
        ulm_canvas.clear();
        ulmscrolltext.draw(0);
        ulmscrollsincount+=1;
       // if (ulmscrollsincount>=ulmscrollsin.length/2)
       // ulmscrollsincount=0;
	
       	ulm_canvas.drawPart(mycanvas_ulm,0,32,50+ulmscrollsin[ulmscrollsincount],0,700,38,1,0,1,1);	 
        ulm_canvas.drawPart(mycanvas_ulm,0,67,50+ulmscrollsin[ulmscrollsincount+4],0,700,38,1,0,1,1);		 
        ulm_canvas.drawPart(mycanvas_ulm,0,102,50+ulmscrollsin[ulmscrollsincount+8],0,700,38,1,0,1,1);		 
        ulm_canvas.drawPart(mycanvas_ulm,0,137,50+ulmscrollsin[ulmscrollsincount+12],0,700,38,1,0,1,1);	
        ulm_canvas.drawPart(mycanvas_ulm,0,172,50+ulmscrollsin[ulmscrollsincount+16],0,700,38,1,0,1,1);	
        ulm_canvas.drawPart(mycanvas_ulm,0,207,50+ulmscrollsin[ulmscrollsincount+20],0,700,38,1,0,1,1);	
        ulm_canvas.drawPart(mycanvas_ulm,0,242,50+ulmscrollsin[ulmscrollsincount+24],0,700,38,1,0,1,1);	
        ulm_canvas.drawPart(mycanvas_ulm,0,277,50+ulmscrollsin[ulmscrollsincount+20],0,700,38,1,0,1,1);	
        ulm_canvas.drawPart(mycanvas_ulm,0,312,50+ulmscrollsin[ulmscrollsincount+16],0,700,38,1,0,1,1);	
        ulm_canvas.drawPart(mycanvas_ulm,0,347,50+ulmscrollsin[ulmscrollsincount+12],0,700,38,1,0,1,1);	
        ulm_canvas.drawPart(mycanvas_ulm,0,382,50+ulmscrollsin[ulmscrollsincount+8],0,700,38,1,0,1,1);	
        ulm_canvas.drawPart(mycanvas_ulm,0,417,50+ulmscrollsin[ulmscrollsincount+4],0,700,38,1,0,1,1);	

        fond_scroll.draw(this.canvaspart,280+Math.sin((vbl_ulm*Math.PI)/200)*150,180+Math.cos((vbl_ulm*Math.PI)/200)*150,0.8,0,1,1);
 
       
        disttimer+=0.1;
        if(disttimer>distformations[distform][3]){
          distform++;			 
          disttimer=0;

          if(distform>=distformations.length)
          distform=0;
        }

        if(distspeed<distformations[distform][0])
            distspeed+=0.001;
            if(distspeed>distformations[distform][0])
            distspeed-=0.001;

        if(distsize<distformations[distform][1])
            distsize+=0.01;
        if(distsize>distformations[distform][1])
            distsize-=0.01;

        if(distgap<distformations[distform][2])
          distgap+=0.001;
        if(distgap>distformations[distform][2])
          distgap-=0.001;

        distadd+=distspeed;
        for(var i=0;i<442;i++){
          distsin=distsize*Math.sin(distadd+i*distgap);	
          mycanvas_ulm.drawPart(this.canvaspart,0+distsin,-6+i,0,26+i,660,1,1,0,1,1);
        }

        vbl_ulm++;
        do_sprite(this.canvaspart);
        mycanvas_ulm.clear();
        this.canvaspart.draw(dest,60,88);
       
       
        if (this.vbl<100) mycanvasblack.draw(dest,60,88,1-this.vbl/100);
        if (this.vbl>intro_parts[part_running].part_duration-100) mycanvasblack.draw(dest,60,88,1-(intro_parts[part_running].part_duration-this.vbl)/100);
        this.vbl++ ;
    }
return this;
}
//////////////
//END PART8//
////////////
