#東方弾幕風
#Title[幼虫「はらぺこあおむし」]
#Text[いもむしうねうね。完全なるネタ弾幕ww。ただうねうねするのをつくってみたかった、それだけなんです。なまえも酷い・・・。]

#BackGround[Default]
#BGM[.\BGM\shooting_star]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
	let count=0;
	let cx=GetCenterX();//STGシーンの中心x座標を取得;
   	let imgBoss   = GetCurrentScriptDirectory~"\img\dot_wriggle.png";

        let power0=GetCurrentScriptDirectory~"SE\power0.wave";
        let tan00=GetCurrentScriptDirectory~"SE\tan00.wave";
	let imgCircle=GetCurrentScriptDirectory~"img\circle6_m.png";
	let imgback02_04=GetCurrentScriptDirectory~"img\back02_04.png";
	let imgAngle=0;
	let flame =0;
	let kira00=GetCurrentScriptDirectory~"SE\kira00.wave";
	let data_usershot=GetCurrentScriptDirectory~"USERSHOT\data_usershot.txt";

        @Initialize
	{
		SetScore(30000);//スペルカードボーナスを30000に設定
		SetLife(550);//ライフを300に設定
		SetDamageRate(10,3);//披ダメージを10%に設定
		SetTimer(80);//時間制限を60秒に設定

		SetGraphicRect(1,1,64,64);//描画元矩形を設定
		SetInvincibility(30);//敵を30フレーム無敵にする
		
		LoadGraphic(imgBoss);//画像「img\ExRumia.png」を読みこむ
		LoadGraphic(imgback02_04);		
		LoadGraphic(imgCircle);
                LoadSE(power0);
		LoadSE(kira00);
		LoadUserShotData(data_usershot);
		SetMovePosition02(cx,100,60);//座標(cx,60)へ60フレームかけて移動する
		Concentration01(150);
		CutIn(YOUMU,"幼虫「はらぺこあおむし」",0,0,0,0,0);//スペルカード名表示
	}
	
	@MainLoop
	{

		
    		let j=rand(0,180);
		SetShotAutoDeleteClip(600,600,600,600);

		if(count==100){PlaySE(power0);}
		if(flame>1000&&count==160){PlaySE(kira00);}

		if(count==150)
			{
          		let dimasama=0;
			let misyakujisama=1;
			let imo=2;
			let i=0;
			let k=0;
     	  		
			loop(9)
           			{
           			CreateShotA(dimasama,GetX,GetY,i);
             			SetShotDataA(dimasama,0,0.1,GetAngleToPlayer,0,0.05,3,GREEN02);
             			SetShotDataA(dimasama,40,NULL,NULL,0,-0.05,0.5,GREEN02);
             			SetShotDataA(dimasama,80,NULL,NULL,0,0.05,3,GREEN02);
             			SetShotDataA(dimasama,120,NULL,NULL,0,-0.05,0.5,GREEN02);
             			SetShotDataA(dimasama,150,NULL,NULL,0,0.05,3,GREEN02);
             			SetShotDataA(dimasama,180,NULL,NULL,0,-0.05,0.5,GREEN02);
             			SetShotDataA(dimasama,210,NULL,NULL,0,0.05,3,GREEN02);
              			SetShotKillTime(dimasama,271);
				

				CreateShotA(misyakujisama,0,0,i);
             			SetShotDataA(misyakujisama,0,0.1,GetAngleToPlayer+180,0,0.05,3,GREEN03);
             			SetShotDataA(misyakujisama,40,NULL,NULL,0,-0.05,0.5,GREEN03);
             			SetShotDataA(misyakujisama,80,NULL,NULL,0,0.05,3,GREEN03);
             			SetShotDataA(misyakujisama,120,NULL,NULL,0,-0.05,0.5,GREEN03);
             			SetShotDataA(misyakujisama,150,NULL,NULL,0,0.05,3,GREEN03);
             			SetShotDataA(misyakujisama,180,NULL,NULL,0,-0.05,0.5,GREEN03);
             			SetShotDataA(misyakujisama,210,NULL,NULL,0,0.05,3,GREEN03);
             			SetShotDataA(misyakujisama,240,NULL,NULL,0,-0.05,0.5,GREEN03);
             			SetShotDataA(misyakujisama,270,NULL,NULL,0,0.05,3,GREEN03);
             			SetShotDataA(misyakujisama,300,NULL,NULL,0,-0.05,0.5,GREEN03);
             			SetShotDataA(misyakujisama,330,NULL,NULL,0,0.05,3,GREEN03);
              			SetShotKillTime(misyakujisama,361);
           	
             			

			let k=0;
			let l=0;
			let tyou=3;
			while(l<13)
				{//360回繰り返
				
					CreateShotA(tyou,0,0,300);
             				SetShotDataA(tyou,0,4.5,k,0,-0.05,1,139);
					SetShotDirectionType(PLAYER);
					SetShotDataA(tyou,90,NULL,0,0,0.03,4,139);
					SetShotDirectionType(ABSOLUTE);
					SetShotKillTime(tyou,600);
					AddShot(360,misyakujisama,tyou,0);
					l+=1;
					k+=15;
					
				}
				

				AddShot(270,dimasama,misyakujisama,0);
             			
				FireShot(dimasama);
              			i+=10;
				}
             	
		}
		
                if(count==300)
			{
			SetShotAutoDeleteClip(300,300,300,300);
			SetMovePositionRandom01(75,40,5,GetClipMinX()+100,80,GetClipMaxX()-100,150);
			count=0;
			}
	

		SetCollisionA(GetX(),GetY(),48);//当たり判定(自弾)登録
		SetCollisionB(GetX(),GetY(),12);//当たり判定(体当たり)登録
		count++;
		flame++;
	}
	
	@Finalize
	{//読みこんだファイルを削除
		DeleteGraphic(imgBoss);		
		DeleteGraphic(imgCircle);
		DeleteGraphic(imgback02_04);
		SetShotAutoDeleteClip(64,64,64,64);
		CreateItem(ITEM_BOMB,GetX,GetY+60);
		loop(8)
		{
			CreateItem(ITEM_SCORE,GetX+rand(-100,100),GetY-rand(20,100));
		}
	}
	
	@DrawLoop
	{
        SetTexture(imgBoss);
	SetAlpha(255);
	SetGraphicAngle(0,0,0);
        SetGraphicRect(0, 0, 128, 128);
        DrawGraphic(GetX, GetY);

		SetGraphicRect(129,1,256,128);
		SetAlpha(100);
		SetGraphicAngle(0,0,-imgAngle);
		SetTexture(imgCircle);
		DrawGraphic(GetX(),GetY());
		imgAngle+=1;
	}

 	@BackGround
	{
	//スペルカード時の背景部分
	//無くてもよい


		SetTexture(imgback02_04);
		SetGraphicRect(1,1,512,512);
		SetAlpha(100);
		SetGraphicAngle(0,0,0);
		DrawGraphic(GetCenterX,GetCenterY);
		
	}

}


	


	
