#TouhouDanmakufu[Plural]
#ScriptVersion[3]
#Title["Umishige no Seki"]
#Text[""]
#Image[""]
#Background[""]
#BGM[""]
SetCommonData("dat",0);
let ss = GetCurrentScriptDirectory~"./Sounds/Music.mp3";
let ss2 = GetCurrentScriptDirectory~"./Sounds/lastw.mp3";
let objmusic = ObjSound_Create;
let objmusic2 = ObjSound_Create;

let bgam = GetCurrentScriptDirectory ~ "./Sounds/st.mp3" ;
let bgam2 = GetCurrentScriptDirectory ~ "./Sounds/lastw.mp3" ;
let sbg=GetCurrentScriptDirectory~"bgg.jpg";

let sss = GetCurrentScriptDirectory ~ "Stg.png" ;
@Initialize{
	ObjSound_Load(objmusic,ss);
	ObjSound_Load(objmusic2,ss2);
	TPlural();
	LoadSound(bgam);
	LoadSound(bgam2);
	bak;
	bak2;
	}

	let vv=0;
	let hhh=0;
	
	task bak{
	
	
	SetPlayerLife(30);
	
let bg1q=ObjPrim_Create(OBJ_SPRITE_2D);
bax(bg1q);
ObjPrim_SetTexture(bg1q,sss);
ObjSprite2D_SetSourceRect(bg1q,0,0,640,480);
ObjRender_SetAlpha(bg1q,255);
ObjSprite2D_SetDestCenter(bg1q);
ObjRender_SetPosition(bg1q,GetStgFrameWidth/2+128,GetStgFrameHeight/2+15,0);
	
	
	//
	
	
let ttt=ObjText_Create;



ObjRender_SetAlpha(ttt,255);
ObjText_SetFontSize(ttt,30);
ObjText_SetFontBorderType(ttt,BORDER_SHADOW);
ObjText_SetFontBorderWidth(ttt,2);
ObjText_SetFontBorderColor(ttt,0,0,0);
//ObjRender_SetPosition(ttt,-1111,SCREEN_HEIGHT/2,0);
ObjText_SetFontType(ttt,"Impact");
ObjText_SetText(ttt," PLAYER ");
ObjRender_SetPosition(ttt,GetStgFrameWidth+80,GetStgFrameHeight/2-160,0);

	
	
	let ttt2=ObjText_Create;



ObjText_SetText(ttt2,IntToString(GetPlayerLife));
ObjRender_SetAlpha(ttt2,255);
ObjText_SetFontSize(ttt2,30);
ObjText_SetFontBorderType(ttt2,BORDER_SHADOW);
ObjText_SetFontBorderWidth(ttt2,4);
ObjText_SetFontBorderColor(ttt2,55,0,111);
//ObjRender_SetPosition(ttt2,-1111,SCREEN_HEIGHT/2,0);
ObjText_SetFontType(ttt2,"Impact");
ObjRender_SetPosition(ttt2,GetStgFrameWidth+180,GetStgFrameHeight/2-162,0);
	
	
	
	
	///
	
	
	
let ttt22=ObjText_Create;



ObjRender_SetAlpha(ttt22,255);
ObjText_SetFontSize(ttt22,30);
ObjText_SetFontBorderType(ttt22,BORDER_SHADOW);
ObjText_SetFontBorderWidth(ttt22,2);
ObjText_SetFontBorderColor(ttt22,0,0,0);
//ObjRender_SetPosition(ttt22,-1111,SCREEN_HEIGHT/2,0);
ObjText_SetFontType(ttt22,"Impact");
ObjText_SetText(ttt22," SPELL ");
ObjRender_SetPosition(ttt22,GetStgFrameWidth+80+7.5,GetStgFrameHeight/2-110,0);
	
	
	
	
	//
	
	
	
	
	
	
	let erer=ObjText_Create;



ObjText_SetText(erer,IntToString(GetPlayerSpell));
ObjRender_SetAlpha(erer,255);
ObjText_SetFontSize(erer,30);
ObjText_SetFontBorderType(erer,BORDER_SHADOW);
ObjText_SetFontBorderWidth(erer,4);
ObjText_SetFontBorderColor(erer,55,0,111);
//ObjRender_SetPosition(erer,-1111,SCREEN_HEIGHT/2,0);
ObjText_SetFontType(erer,"Impact");
ObjRender_SetPosition(erer,GetStgFrameWidth+180,GetStgFrameHeight/2-112,0);
	
	
	
	
task bax(vv){

while(!Obj_IsDeleted(vv)){






yield;
ObjRender_SetAlpha(bg1q,255);
ObjRender_SetScaleXYZ(bg1q,1,1,1);


Obj_SetRenderPriorityI(bg1q,90);
Obj_SetRenderPriorityI(ttt,91);



Obj_SetRenderPriorityI(ttt2,91);
Obj_SetRenderPriorityI(ttt22,91);
Obj_SetRenderPriorityI(erer,91);
ObjText_SetText(ttt2,IntToString(GetPlayerLife));
ObjText_SetText(erer,IntToString(GetPlayerSpell));
}
}


	
	
	
	}
	
	
	
	
	task bak2{
	
	
	
	
let bg1q=ObjPrim_Create(OBJ_SPRITE_2D);
bax(bg1q);
ObjPrim_SetTexture(bg1q,sbg);
ObjSprite2D_SetSourceRect(bg1q,0,0,1000,800);
ObjRender_SetAlpha(bg1q,255);
ObjSprite2D_SetDestCenter(bg1q);
ObjRender_SetPosition(bg1q,GetStgFrameWidth/2+150,230,0);
	
	
	
task bax(vv){

while(!Obj_IsDeleted(vv)){
yield;
ObjRender_SetAlpha(bg1q,255);

Obj_SetRenderPriorityI(bg1q,20);
ObjRender_SetAngleZ(vv,1-cos(hhh));
ObjRender_SetScaleXYZ(vv,1,1,1);
hhh+=1;
}
}


	
	
	
	}
	
@MainLoop{yield;}

@Finalize{}

task lll{loop{yield;DeleteShotInCircle(TYPE_ALL,TYPE_IMMEDIATE,0,0,2);}}

task TPlural{lll;
ObjSound_Play(objmusic);
	let dir = GetCurrentScriptDirectory();
	
	SetCommonData("dat",0);
	
	
	let obj = ObjEnemyBossScene_Create();
	ObjEnemyBossScene_Add(obj, 0, dir ~ "Non1.txt");
	ObjEnemyBossScene_Add(obj, 0, dir ~ "Sp1.txt");
	
	ObjEnemyBossScene_Add(obj, 1, dir ~ "Non2.txt");
	
	ObjEnemyBossScene_Add(obj, 1, dir ~ "Sp2.txt");
	
	
			
	ObjEnemyBossScene_Add(obj, 2, dir ~ "Non3.txt");
	ObjEnemyBossScene_Add(obj, 2, dir ~ "Sp3.txt");
	
	
			  
			  
	
	ObjEnemyBossScene_Add(obj, 3, dir ~ "SpL.txt");		  
			  
			  
	ObjEnemyBossScene_LoadInThread(obj);
	ObjEnemyBossScene_Regist(obj);
	
	while(!Obj_IsDeleted(obj)){
	
	PlayBGM(bgam,0,379);
	if(GetCommonData("dat",1)){yield;
	loop(100){

	ObjSound_SetVolumeRate(objmusic,ObjSound_GetVolumeRate(objmusic)-1);yield;}
	loop(185){yield;}
	
	yield;
	break;
	
	}
	
	
	
	
	yield;}

	while(!Obj_IsDeleted(obj)){yield;}
		
	CloseScript(GetOwnScriptID());}