#TouhouDanmakufu[Stage]
#Title[Yui-chan uEasyv]
#Text[Eeeh Maji!? Easy Modo??]
#Image[.\Img\yuimage.png]
#Player[REIMU,MARISA]
#ScriptVersion[2]

script_stage_main
{
	//let bgm=GetCurrentScriptDirectory~"Spell\yuugi.mp3";
   let bg_distance = 0;
let FORE = GetCurrentScriptDirectory~"Img\fore.png";
let foreg=0;
let partframe=0;
let trigger=false;
let c = 0;
let a = 0;
let pointnorm=50;
let start=0;
let NameOff=0;

let img_bg=GetCurrentScriptDirectory~"Img\yuibackb.png";
let img_bgb=GetCurrentScriptDirectory~"Img\fog.png";
let black=GetCurrentScriptDirectory~"Img\black.png";
let anim=0;
let type=0;
let bgdist=0;
let rot=0;
let alpha=255;
let drawangle=0;

task stage
{
 if(GetPlayerScriptName=="REIMU"){
	loop(100){yield;}
	CreateEnemyBossFromFile(GetCurrentScriptDirectory~"Yui_ER.txt", GetCenterX, GetClipMinY-20, 0, 0, 0);
	loop(240){yield;}
	//PlayMusic(bgm);
	while(GetEnemyNum!=0){yield;}
        CreateEnemyBossFromFile(GetCurrentScriptDirectory~"YFR.txt", GetCenterX, GetClipMinY-20, 0, 0, 0);
	loop(240){yield;}
	//PlayMusic(bgm);
	while(GetEnemyNum!=0){yield;}
	loop(60){yield;}
}
else if(GetPlayerScriptName=="MARISA"){
	loop(100){yield;}
	CreateEnemyBossFromFile(GetCurrentScriptDirectory~"Yui_EM.txt", GetCenterX, GetClipMinY-20, 0, 0, 0);
	loop(240){yield;}
	//PlayMusic(bgm);
	while(GetEnemyNum!=0){yield;}
        CreateEnemyBossFromFile(GetCurrentScriptDirectory~"YFM.txt", GetCenterX, GetClipMinY-20, 0, 0, 0);
	loop(240){yield;}
	//PlayMusic(bgm);
	while(GetEnemyNum!=0){yield;}
	loop(60){yield;}
}

	Clear;
	}
	task Foreground{
	let obj=Obj_Create(OBJ_EFFECT);
	Obj_SetX(obj,192);
	Obj_SetY(obj,192);
	ObjEffect_SetLayer(obj,8);
	ObjEffect_SetTexture(obj,FORE);
	ObjEffect_SetPrimitiveType(obj,PRIMITIVE_TRIANGLEFAN);
	ObjEffect_SetRenderState(obj,ALPHA);
	ObjEffect_SetAngle(obj,0,0,0);

let s = 1;
ObjEffect_SetScale(obj,s,s);

ObjEffect_CreateVertex(obj,4);
ObjEffect_SetVertexUV(obj,0,0,0);
ObjEffect_SetVertexUV(obj,1,640,0);
ObjEffect_SetVertexUV(obj,2,640,480);
ObjEffect_SetVertexUV(obj,3,0,480);

ObjEffect_SetVertexXY(obj,0,-192,-192);
ObjEffect_SetVertexXY(obj,1,448,-192);
ObjEffect_SetVertexXY(obj,2,448,288);
ObjEffect_SetVertexXY(obj,3,-192,288);

	loop{yield;}
	}
   @Initialize
   {
        LoadGraphic(black);
        LoadGraphic(img_bg);
        LoadGraphic(img_bgb);
        LoadGraphic(FORE);
	stage;
   }

   @MainLoop
   {
	if(foreg==0){Foreground;foreg=1}
	yield;
		partframe++;
		if(partframe%5==0 && OnEnemySpell==false){
			//particles(rand(GetClipMinX,GetClipMaxX),GetClipMinY,rand(0.1,0.5));
		}
	
		if(trigger==false){c +=0.05;}else if(trigger==true){c-= 0.05}
		if(c >= 80) {trigger=true}
		if(c<= -80){trigger=false}
		
   }

   @DrawLoop
   {

   }

   @BackGround
   {
	SetTexture(black);
	SetGraphicRect(-1024, -1024, 1024, 1024);
	SetGraphicAngle(0, 0, 0);
    SetRenderState(ALPHA);
	SetAlpha(255);
	DrawGraphic(GetCenterX, GetCenterY);
	SetTexture(img_bg);
	SetGraphicRect(0, 0, 256, 256);
	SetGraphicAngle(0, 0, 0);
	SetGraphicScale(3, 3);
	SetAlpha(175);
	DrawGraphic(GetCenterX, GetCenterY);
	SetTexture(img_bgb);
	SetGraphicRect(0, 0, 256, 256);
	SetGraphicAngle(0, 0, 0);
	SetGraphicScale(3, 3);
	SetAlpha(100);
	DrawGraphic(GetCenterX, GetCenterY);
	//rot+=0.5;
   }

   @Finalize
   {
   }
}
