#TouhouDanmakufu
#Title[Confiment "Clastrophobia"]
#Text[How do you feel?]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
    let ImgBoss = "script\img\ExRumia.png";
	let shot = GetCurrentScriptDirectory~"shot.wav";
    let frame = -120;
#include_function ".\lib\SHOT_REPLACE\shot_replace.dnh"
	let background = GetCurrentScriptDirectory~"patchybackground.png";

    @Initialize {
        SetLife(4200);
        SetTimer(50);
        SetScore(1000000);
	SetInvincibility(180);
	SetDamageRate(85, 10);
	shotinit;
	LoadSE(shot);
	LoadGraphic(background);
        SetMovePosition02(GetCenterX, GetClipMinY + 120, 120);
        CutIn(KOUMA, "Confinement"\""Claustrophobia"\", GetCurrentScriptDirectory~"rumia.png", 0, 0, 128, 256);
        LoadGraphic(ImgBoss);
        SetTexture(ImgBoss);
        SetGraphicRect(0, 0, 64, 64);
    }

    @MainLoop {
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);

        



if(frame == 40){

	let a   = 3;
        let num = 5; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, a+GetAngleToPlayer, BLUE02, 0);
            a += 30/num;
	    
	PlaySE(shot);
}

}

if(frame == 40){

	let a   = 3;
        let num = 5; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, a+GetAngleToPlayer, BLUE02, 0);
            a += -30/num;
	
	    

}

}



if(frame == 80){

	let a   = 0;
        let num = 5; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, a+GetAngleToPlayer, BLUE02, 0);
            a += 30/num;
	    PlaySE(shot);

}

}

if(frame == 80){

	let a   = 0;
        let num = 5; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, a+GetAngleToPlayer, BLUE02, 0);
            a += -30/num;
	
	    

}

}


if(frame == 120){

	let a   = 0;
        let num = 5; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, a+GetAngleToPlayer, BLUE02, 0);
            a += 30/num;
	  
}

}

if(frame == 120){

	let a   = 0;
        let num = 5; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, a+GetAngleToPlayer, BLUE02, 0);
            a += -30/num;
	PlaySE(shot);
	    

}

}

if(frame == 160){

	let a   = 6;
        let num = 5; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, a+GetAngleToPlayer, BLUE02, 0);
            a += 30/num;
	    PlaySE(shot);

}

}

if(frame == 160){

	let a   = 6;
        let num = 5; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, a+GetAngleToPlayer, BLUE02, 0);
            a += -30/num;
	
	    

}

}

if(frame == 200){

	let a   = 0;
        let num = 5; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, a+GetAngleToPlayer, BLUE02, 0);
            a += 30/num;
	    	PlaySE(shot);
}

}

if(frame == 200){

	let a   = 0;
        let num = 5; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, a+GetAngleToPlayer, BLUE02, 0);
            a += -30/num;
	
	    

}

}

if(frame == 40){

	let a   = 5;
        let num = 20; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
		
            CreateShot01(GetX, GetY, 5, a+GetAngleToPlayer, BLUE03, 0);
		a += 360/num
 
	    

}
}



if(frame == 100){
	SetMovePosition03(GetX, 50+GetY, 1, 1.25);
	}

if(frame == 201){
	SetMovePosition03(GetX, -50+GetY, 1, 1.25);
	frame=0;
	}


        frame++;
    }

   @DrawLoop {
	SetTexture(ImgBoss);
                SetRenderState(ALPHA);
                SetAlpha(255);  
                SetGraphicScale(1,1);
                SetGraphicAngle(0,0,0);

                if(GetSpeedX==0){
                         SetGraphicRect(0,0,64,64); }
                        
 
                if(GetSpeedX>0){
                        SetGraphicRect(190, 126, 256, 64);
			}
 
                if(GetSpeedX<0){
                        
                        SetGraphicRect(128,128,186,64); }
                      
 
                DrawGraphic(GetX,GetY);
    }

let y = 0;

@BackGround{
   SetTexture(background);
   SetGraphicRect(0, 0 - y, 512, 512 - y);
   DrawGraphic(GetCenterX, GetCenterY);
   y++;
}

    @Finalize {
        DeleteGraphic(ImgBoss);
    }
}