#東方弾幕風
#Title[筒粥「神の粥」]
#Text[]
#BackGround[Default]
#ScriptVersion[2]

script_enemy_main{

	#include_function ".\lib\lib_anime_Sanae.txt"
	let imgBoss = GetCurrentScriptDirectory() ~ "img\dot_sanae.png";
	let shot  =GetCurrentScriptDirectory~"SE\arrow01.wav";
	let shot2  =GetCurrentScriptDirectory~"SE\kira01_r.wav";
	let shot3  =GetCurrentScriptDirectory~"SE\shoot13.wav";
	let Concentration  =GetCurrentScriptDirectory~"SE\eco00_r.wav";
	let Back=GetCurrentScriptDirectory~"img\kikuBack.png";
	let sippou=GetCurrentScriptDirectory~"img\sippou.png";
	let r  =105;
	let g  =105;
	let b  =105;
	let wIni = 120;

	@Initialize{
	LoadGraphic(imgBoss);
	LoadGraphic(Back);
	LoadGraphic(sippou);
	LoadUserShotData(GetCurrentScriptDirectory ~ "img\shot_All.txt");
        SetMovePosition02(GetCenterX(), 200, wIni/2);
        SetAction(ACT_MOVE, wIni/2);
        SetLife(200);
        SetTimer(70);
        SetInvincibility(wIni*2);
        SetDamageRate(8.5, 1.5);
	LoadGraphic(GetCurrentScriptDirectory~"img\back06_01.png");	
	InitializeAction();
	    
	GMain;
	TMain;
	}
		
	@MainLoop{
		SetCollisionA(GetX(), GetY(), 32);
		SetCollisionB(GetX(), GetY(), 24);
	    yield;
	}
let BGx=0;
let BGy=0;
@BackGround{
		SetTexture(Back);
		SetGraphicRect(0,0,500,500);
		SetGraphicAngle(0, 0, 0);
		SetAlpha(155);
		SetColor(200,200,200);
		SetGraphicExpansion(1,1);
		DrawGraphic(224, 240); 

		SetTexture(sippou);
		SetGraphicRect(BGx,BGy,BGx+450,BGy+50000);
		SetRenderState(ADD);
		SetGraphicAngle(0, 0, 0);
		SetAlpha(100);
		SetColor(r,g,b);
		SetGraphicExpansion(1,1);
		DrawGraphic(224, 240);
		BGy-=1;
	}	  
		
	@Finalize{
	DeleteGraphic(imgBoss);
	}
	
	
		task GMain{
		loop{
		loop(50){
		r+=2;
		b-=2;
	    loop(4){ yield; }
			}
		loop(50){
		g+=2;
		r-=2;
	    loop(4){ yield; }
			}
		loop(50){
		b+=2;
		g-=2;
	    loop(4){ yield; }
			}
			}
			}
	task TMain{
	    SetAction(ACT_MOVE, wIni/2);
	    yield;
	    loop(wIni/2){ yield; }
        CutIn(YOUMU, "筒粥「神の粥」", "", 0, 0, 0, 0);
          SetAction(ACT_SHOT_B,12000);
        SetScore(14000000/3);
	    loop(wIni/2){ yield; }
	    	    let a=rand(0,360);
	    loop{
			a=rand(0,360);
	    loop(51){
rice(GetX+30,GetY-20,7,a,0.085,1.5,65,41,75);
		a+=360/48;
		}
			a=rand(0,360);
	    loop(51){
rice(GetX-30,GetY-20,7,a,0.085,1.5,71,47,75);
		a+=360/48;
		}
                PlaySE(shot);
	        loop(45){ yield; }
	    }
			}
task rice(let X,let Y,let speed,let angle,let mspeed,let lspeed,let color1,let color2,let delay){
        let obj = Obj_Create(OBJ_SHOT);
        Obj_SetPosition(obj, X, Y);
        Obj_SetSpeed(obj, speed);
        Obj_SetAngle(obj, angle);
        ObjShot_SetGraphic(obj, color1);
        ObjShot_SetDelay(obj, 10);
	loop(delay){
if(speed>lspeed){
speed-=mspeed;
		}
if(speed<lspeed){
speed=lspeed;
		}
Obj_SetSpeed(obj, speed);yield;}
        while(!Obj_BeDeleted(obj)) {
rice2(Obj_GetX(obj),Obj_GetY(obj),lspeed,angle,color2);
Obj_Delete(obj);
yield; 
	}
	}
task rice2(let X,let Y,let speed,let angle,let color){
        let obj = Obj_Create(OBJ_SHOT);
        Obj_SetPosition(obj, X, Y);
        Obj_SetSpeed(obj, speed);
        Obj_SetAngle(obj, angle);
        ObjShot_SetGraphic(obj, color);
        ObjShot_SetDelay(obj, 10);
	loop(100){
SetCollisionB(Obj_GetX(obj),Obj_GetY(obj),8);
SetCollisionB(Obj_GetX(obj)+6*cos(angle),Obj_GetY(obj)+3*sin(angle),6);
SetCollisionB(Obj_GetX(obj)+6*cos(angle+180),Obj_GetY(obj)+3*sin(angle+180),6);
yield;
		}
Obj_Delete(obj);
	}
	@DrawLoop{
	  DrawBoss(imgBoss);
		DrawGraphic(GetX(),GetY());
	}
        

}
