	#東方弾幕風[Stage]
	#Title[Incredible Daily Tale ver1.61]
	#Text[Incredible Daily Tale ver1.61]
	#Player[ .\player/ReimuA/ReimuA.txt, .\player/ReimuB/ReimuB.txt, .\player/MarisaA/MarisaA.txt, .\player/MarisaB/MarisaB.txt]
	#BackGround[User]
	#BackGround[Defalt]
	#ScriptVersion[2]


	
	script_stage_main
	{
	SetRateScoreSystemEnable(false);
	SetDefaultStatusVisible(false);
	let csd=GetCurrentScriptDirectory;
	let imgBG=csd ~ "img/MenuBG.png";
	let imgItem=csd ~ "img/Item.png";
	let imgDifficult=csd ~ "img/letter.png";
	let imgResult=csd ~ "img/resultletter.png";
	let imgPlayerAndBomb=csd ~ "img/shot_all.png";
	let imgMenuEffect=csd ~ "img/effect_tiny.png";

	SetCommonData("ItemXY",[]);//アイテム位置座標保存用共通データ作成

	let MenuSE=[csd ~ "se/clock03.wav",csd ~ "se/cursor01.wav"];
	let BGM=[csd ~ "bgm/menu.wav",csd ~ "bgm/stage1.wav",csd ~ "bgm/stage1boss.wav",csd ~ "bgm/stage2.wav",csd ~ "bgm/stage2boss.wav",csd ~ "bgm/stage3.wav",csd ~ "bgm/stage3boss.wav",
		csd ~ "bgm/stage4.wav",csd ~ "bgm/stage4boss.wav",csd ~ "bgm/stage5.wav",csd ~ "bgm/stage5boss.wav",csd ~ "bgm/stage6.wav",csd ~ "bgm/stage6boss.wav"];

	let Hiscore=[];
	let Hiscore2=[];
	ascent(let k in 0..10)
	{
		Hiscore = Hiscore ~ [k];
		Hiscore2 = Hiscore2 ~ [k];
	}

	let SelectedDifficult="Difficult";
	let StageProgress=1;
	let StagePractice=false;

	let bgX=0;
	let bgX2=300;
	let bgrt=0;
	let stage1alpha1=0;
	let stage1alpha2=0;
	let stage2alpha=0;
	let stage3alpha=0;
	let stage4alpha1=0;
	let stage4alpha2=0;
	let stage5alpha1=0;
	let stage5alpha2=0;
	let stage6alpha1=0;
	let stage6alpha2=0;

	let ScoreNumber1=0;
	let ScoreNumber2=0;

	let BGDrawing;
	let GetItemScoreDrawing;
	let ItemPointerDrawing;

	#include_function ".\txt\DifineMenuVariable.txt"//メニュー画面管理用の値の収納先
	#include_function ".\Config.txt"
		task StageTask
		{
			yield;
			LifeAndBombDefine;
			PlayMusic(BGM[0]);
			UpTimeCount;//起動時間計測
			PlayTimeCount;//プレイ時間計測

			MenuEffect;//メニューの紅葉
			EnemyMagicCircle;//敵スペル時の魔方陣
			EnemyLifeDisplay;//下部にボスのライフを表示
			StageTitleDisplay;
			StatusDisplay;//文字を表示
			PlayerAndBombDisplay;//残機とボム表示
			ForbidShot(false);
			ForbidBomb(false);
			CheckItem;//アイテム生成開始
			PlayCharacterAndDifficult;//使用キャラと難易度のプレイ回数の記録
			HiScoreLoad;//ハイスコアをロード
			DifficultDisplay;//難易度を表示
			DisPlayScore;//スコアを表示
			SCBItem;//スペルカード取得ボーナスアイテムタスク起動
			ExtendSystem;
			if(BGDrawing==1)
			{
				BGGraphicRect;//ステージ背景の矩形処理など
			}
			DeleteUsedFile;
			if(StageProgress==1)
			{
				Stage1;
				SetCommonData("STAGEPROGRESS",1);
				while(StageProgress==1){yield;}
				if(StagePractice==true)
				{
					StageProgress=1;
					wait(240);
					ClearStage;
				}
			wait(60);
			}
//			StageCrear;
//			NextStage;
//			CrearBonus;
			AddGraze(-GetGraze);
			if(StageProgress==2)
			{
				Stage2;
				SetCommonData("STAGEPROGRESS",2);
				while(StageProgress==2){yield;}
				if(StagePractice==true)
				{
					StageProgress=2;
					wait(240);
					ClearStage;
				}
			DeleteGraphic(csd~"img\stage2bg.png");
			wait(60);
//			StageCrear;
//			NextStage;
			AddGraze(-GetGraze);
			}
			if(StageProgress==3)
			{
				Stage3;
				SetCommonData("STAGEPROGRESS",3);
				while(StageProgress==3){yield;}
				if(StagePractice==true)
				{
					StageProgress=3;
					wait(240);
					ClearStage;
				}
			wait(60);
//			StageCrear;
//			NextStage;
			AddGraze(-GetGraze);
			}

			if(StageProgress==4)
			{
				Stage4;
				SetCommonData("STAGEPROGRESS",4);
				while(StageProgress==4){yield;}
				if(StagePractice==true)
				{
					StageProgress=4;
					wait(240);
					ClearStage;
				}
			DeleteGraphic(csd~"img\stage4bg.png");
			wait(60);
//			StageCrear;
//			NextStage;
			AddGraze(-GetGraze);
			}

			if(StageProgress==5)
			{
				Stage5;
				SetCommonData("STAGEPROGRESS",5);
				while(StageProgress==5){yield;}
				if(StagePractice==true)
				{
					StageProgress=5;
					wait(240);
					ClearStage;
				}
			DeleteGraphic(csd~"img\stage5bg.png");
			wait(60);
//			StageCrear;
//			NextStage;
			AddGraze(-GetGraze);
			}

			if(StageProgress==6)
			{
				Stage6;
				SetCommonData("STAGEPROGRESS",6);
				while(StageProgress==6){yield;}
				if(StagePractice==true)
				{
					StageProgress=6;
					wait(240);
					ClearStage;
				}
			SetCommonData("STAGECLEAR",true);
			wait(120);
			}
			StageCrear;
			NextStage;
			CrearBonus;
			wait(600);
			if(Continued==false && StagePractice==false)
			{
				SetCommonDataEx(NsScore,"SecretFlag","true");
				SetCommonDataEx(NsScore,"ExFlag","true");
			}
			ClearStage;
		}
	
		
		@Initialize()
		{
			ExpertEx(false,1,3);
			LoadGraphic(csd~"img\stage1bg.png");		//画像データの読み込み
			LoadGraphic(csd ~ "stg2bg.png");
			LoadGraphic(imgBG);
			LoadGraphic(imgItem);
			LoadGraphic(imgDifficult);
			LoadGraphic(imgResult);
			LoadGraphic(imgPlayerAndBomb);
			LoadGraphic(csd ~ "img/border.png");
			LoadGraphic(imgMenuEffect);
      			LoadGraphic(csd~"img\circle.png");
			LoadGraphic(csd ~ "img\spellname.png");
			if(BGDrawing==1)
			{
			LoadGraphic(csd ~ "img\White.png");
			LoadGraphic(csd ~ "img\fog.png");
			LoadGraphic(csd ~ "img\stage2bg.png");
			LoadGraphic(csd ~ "img\stage3bg.png");
			LoadGraphic(csd ~ "img\stage4bg.png");
			LoadGraphic(csd ~ "img\stage5bg.png");
			LoadGraphic(csd ~ "img\stage6bg.png");
			}
			LoadGraphic(csd ~ "img\ber.png");
			//ここから妖精と魔方陣の画像ロード
			//LoadGraphic(csd~"lib/fairy_green.png");
			//LoadGraphic(csd~"img/familiar.png");
			//ここまで
			CreateCommonDataArea(NsScore);
			LoadCommonDataEx(NsScore,savePathstage);
			SetCommonData(NsGetSpell,0);
			let isRep = IsReplay();
			SetCommonData(NsIsReplay,isRep);
			StageTask();
		}
	
		@MainLoop()
		{
			yield;
			if(OnPlayerMissed)
			{
				SetCommonData("Playermissed",true);
			}
			else
			{
				SetCommonData("Playermissed",false);
			}

		}
		

		@DrawTopObject
		{
			SetTexture(imgBG);
			SetGraphicScale(1.0,1.0);
			SetGraphicRect(0,0,384,448);
			if(StageState==Menu)
			{
				SetGraphicAngle(0, 0, 0);
				SetViewTo(0,0,0);
				DrawGraphic(GetCenterX, GetCenterY);
			}
			//DrawText(NumToString(GetCommonDataDefaultEx(NsScore,NsUpTime,0)/60),320,432,12,255);//起動時間の表示
			//DrawText(NumToString(GetCommonDataDefaultEx(NsScore,NsPlayTime,0)/60),320,452,12,255);//プレイ時間の表示
			//DrawText(StageState,120,432,12,255);//起動時間の表示
			//DrawText(DefinedPlayer1,120,452,12,255);//プレイ時間の表示
			//DrawText(SelectedCharacter,120,412,12,255);//起動時間の表示
			MenuDraw;
		}

		@Finalize()
		{
			SetCommonDataEx(NsScore,"ExFlag","true");
			HiScoreSave;
			if(GetCommonDataDefault(NsIsReplay,true) == false)
			{
				SaveCommonDataEx(NsScore,savePathstage);
			}
			ClearCommonDataEx(NsScore);
			DeleteCommonData(NsGetSpell);
			DeleteCommonData(NsDefeatFrame);
			DeleteCommonData(NsDefeatPosX);
			DeleteCommonData(NsDefeatPosY);
			DeleteCommonData(NsBossFrame);
			DeleteCommonData(NsIsReplay);
		}
		@BackGround {
		if(StageState!=Menu && BGDrawing==1)
		{
			if(StageProgress==1)
			{
				SetTexture(csd~"img\stage1bg.png");		//画像の貼り付け
				SetGraphicRect(0 + bgX, 0+bgX  ,6000 + bgX, 6000+ bgX);	//描画矩形の設定
				SetGraphicAngle(-110, 0, 0);
				SetGraphicScale(0.2,0.2);
			SetAlpha(stage1alpha1);
				SetViewTo(0,-160,50);
				SetColor(200,200,255);
				DrawGraphic3D(0, 0, 0);				//実際に表示
				SetFog(200,500,200,200,250);
				SetTexture(csd~"img\stage1bg.png");		//画像の貼り付け
				SetGraphicRect(0-bgX2, 0+bgX2  ,6000-bgX2, 6000 + bgX2);	//描画矩形の設定			//実際に表示
				SetGraphicAngle(-110, 0, 0);
				SetGraphicScale(0.2,0.2);
			SetAlpha(stage1alpha2);
				SetViewTo(0,-160,50);
				SetColor(200,200,255);
				DrawGraphic3D(0, 0, 0);

				SetTexture(csd~"img\White.png");
				SetGraphicScale(1.0,1.0);
				SetGraphicRect(0,0,6000,6000);
				SetGraphicAngle(0, 0, 0);
				//SetViewTo(0,0,0);
				SetAlpha(30);
				//DrawGraphic(GetCenterX, GetCenterY);
				DrawGraphic3D(0, 0, 0);
			}
			if(StageProgress==2)
			{			//実際に表示
				SetFog(200,500,100,100,100);
				SetTexture(csd~"img\stage2bg.png");		//画像の貼り付け
				SetGraphicRect(0, 0+bgX2  ,1280, 1280 + bgX2);	//描画矩形の設定			//実際に表示
				SetGraphicAngle(-110, 0, 0);
				//SetGraphicScale(0.2,0.2);
			SetAlpha(stage2alpha);
				SetViewTo(0,-160,50);
				SetColor(200,255,255);
				SetViewFrom(500, 90, 75);
				DrawGraphic3D(0, 0, 0);

				SetGraphicScale(2,2);	
		
				SetTexture(csd ~ "img\fog.png");
				SetGraphicRect(0, 0 + 2*bgrt, 384, 512 + 2*bgrt);
				SetGraphicAngle(-110, 0, 0);
			//	SetViewFrom(300, 90, 80);
			//	SetViewTo(0, 0, 0);
				SetAlpha(100);
				//SetPerspectiveClip(10,450);		
				//SetFog(220, 540, 0, 0,0);
				SetColor(255, 255, 255);
				DrawGraphic3D(0, 0, 0);
			}

			if(StageProgress==3)
			{			//実際に表示
				SetFog(200,500,100,100,100);
				SetTexture(csd~"img\stage3bg.png");		//画像の貼り付け
				SetGraphicRect(0, 0+bgX2  ,1280, 1280 + bgX2);	//描画矩形の設定			//実際に表示
				SetGraphicAngle(-110, 0, 0);
				//SetGraphicScale(0.2,0.2);
			SetAlpha(stage3alpha);
				SetViewTo(0,-160,50);
				SetColor(255, 100, 255);
				SetViewFrom(500, 90, 75);
				DrawGraphic3D(0, 0, 0);

				SetGraphicScale(2,2);	
		
				SetTexture(csd ~ "img\fog.png");
				SetGraphicRect(0, 0 + 2*bgrt, 384, 512 + 2*bgrt);
				SetGraphicAngle(-110, 0, 0);
			//	SetViewFrom(300, 90, 80);
			//	SetViewTo(0, 0, 0);
				SetAlpha(100);
				//SetPerspectiveClip(10,450);		
				//SetFog(220, 540, 0, 0,0);
				SetColor(255, 100, 255);
				DrawGraphic3D(0, 0, 0);
			}

			if(StageProgress==4)
			{			//実際に表示
				//SetFog(200,500,200,200,250);
				SetTexture(csd~"img\stage4bg.png");		//画像の貼り付け
				SetGraphicRect(0, 0+bgX2  ,2560, 2560 + bgX2);	//描画矩形の設定			//実際に表示
				SetGraphicAngle(-110, 0, 0);
				SetGraphicScale(0.2,0.2);
				SetAlpha(stage4alpha1);
				SetViewTo(0,-160,50);
				SetColor(255, 255, 255);
				SetViewFrom(500, 90, 75);
				DrawGraphic3D(0, 0, 0);

				SetTexture(csd~"img\stage3bg.png");		//画像の貼り付け
				SetGraphicRect(0, 0+bgX2  ,1280, 1280 + bgX2);	//描画矩形の設定			//実際に表示
				SetGraphicAngle(-110, 0, 0);
				SetGraphicScale(1,1);
				SetAlpha(stage4alpha2);
				SetViewTo(0,-160,50);
				SetColor(200,255,255);
				SetViewFrom(500, 90, 75);
				DrawGraphic3D(0, 0, 0);

				SetGraphicScale(2,2);	
				SetFog(0, 50, 150, 150, 250);	
				SetTexture(csd ~ "img\fog.png");
				SetGraphicRect(0, 0 + 2*bgrt, 384, 512 + 2*bgrt);
				SetGraphicAngle(-110, 0, 0);
			//	SetViewFrom(300, 90, 80);
			//	SetViewTo(0, 0, 0);
				SetAlpha(100);
				//SetPerspectiveClip(10,450);		
				//SetFog(220, 540, 0, 0,0);
				SetColor(255, 255, 255);
				DrawGraphic3D(0, 0, 0);
			}
			if(StageProgress==5)
			{


				SetTexture(csd~"img\stage1bg.png");		//画像の貼り付け
				SetGraphicRect(0 + bgX, 0+bgX  ,6000 + bgX, 6000+ bgX);	//描画矩形の設定
				SetGraphicAngle(-110, 0, 0);
				SetGraphicScale(0.2,0.2);
			SetAlpha(stage5alpha1);
				SetViewTo(0,-160,50);
				SetColor(200,200,255);
				DrawGraphic3D(0, -60, 0);				//実際に表示
				SetFog(100,500,50,0,50);
				SetTexture(csd~"img\stage1bg.png");		//画像の貼り付け
				SetGraphicRect(0-bgX2, 0+bgX2  ,6000-bgX2, 6000 + bgX2);	//描画矩形の設定			//実際に表示
				SetGraphicAngle(-110, 0, 0);
				SetGraphicScale(0.2,0.2);
			SetAlpha(stage5alpha2);
				SetViewTo(0,-160,50);
				SetColor(200,200,255);
				DrawGraphic3D(0, -60, 0);

				SetTexture(csd~"img\stage5bg.png");		//画像の貼り付け
				SetGraphicRect(0, 0 ,640, 260);	//描画矩形の設定			//実際に表示
				SetGraphicAngle(0, 0, 180);
				SetGraphicScale(1,0.5);
				SetAlpha(100);
				SetViewTo(0,0,0);
				SetColor(200,255,255);
				SetViewFrom(500, 90, 45);
				DrawGraphic3D(0, 180, 0);

				SetGraphicScale(2,2);	
		
				SetTexture(csd ~ "img\fog.png");
				SetGraphicRect(0, 0 + 2*bgrt, 384, 512 + 2*bgrt);
				SetGraphicAngle(-110, 0, 0);
			//	SetViewFrom(300, 90, 80);
			//	SetViewTo(0, 0, 0);
				SetAlpha(100);
				//SetPerspectiveClip(10,450);		
				//SetFog(220, 540, 0, 0,0);
				SetColor(255, 100, 255);
				DrawGraphic3D(0, 0, 0);
			}
			if(StageProgress>=6)
			{


				SetTexture(csd~"img\stage6bg.png");		//画像の貼り付け
				SetGraphicRect(0 + bgX, 0+bgX  ,6000 + bgX, 6000+ bgX);	//描画矩形の設定
				SetGraphicAngle(-120, 0, 0);
				SetGraphicScale(0.2,0.2);
			SetAlpha(stage6alpha1);
				SetViewTo(0,-160,50);
				SetColor(200,200,255);
				DrawGraphic3D(0, -60, 0);				//実際に表示
				SetFog(100,500,50,0,50);
				SetTexture(csd~"img\stage6bg.png");		//画像の貼り付け
				SetGraphicRect(0-bgX2, 0+bgX2  ,6000-bgX2, 6000 + bgX2);	//描画矩形の設定			//実際に表示
				SetGraphicAngle(-120, 0, 0);
				SetGraphicScale(0.2,0.2);
			SetAlpha(stage6alpha2);
				SetViewTo(0,-160,50);
				SetColor(200,200,255);
				DrawGraphic3D(0, -60, 0);

				SetGraphicScale(2,2);	
		
				SetTexture(csd ~ "img\fog.png");
				SetGraphicRect(0, 0 + 2*bgrt, 384, 512 + 2*bgrt);
				SetGraphicAngle(-110, 0, 0);
			//	SetViewFrom(300, 90, 80);
			//	SetViewTo(0, 0, 0);
				SetAlpha(50);
				//SetPerspectiveClip(10,450);		
				//SetFog(220, 540, 0, 0,0);
				SetColor(255, 100, 255);
				DrawGraphic3D(0, 0, 0);
			}
		}	
	}

task BGGraphicRect
{
	while(StageProgress==1)
	{
		if(stage1alpha1<=80)
		{
			stage1alpha1+=80/240;
		}
		if(stage1alpha2<=120)
		{
			stage1alpha2+=120/240;
		}
			bgX += 1;
			if (bgX >= 6000)
			{
				bgX = 0;
			}
			bgX2 += 1;
			if (bgX >= 6000)
			{
				bgX2 = 0;
			}
		yield;
	}
	while(StageProgress==2)
	{
		if(stage2alpha<=150)
		{
			stage2alpha+=150/240;
		}
			bgX += 1;
			if (bgX >= 6000)
			{
				bgX = 0;
			}
			bgX2 += 1;
			if (bgX >= 6000)
			{
				bgX2 = 0;
			}
				bgrt += 1;
				if(bgrt > 512){bgrt = bgrt - 512;}
				if(bgrt <   0){bgrt = bgrt + 512;}
		yield;
	}
	while(StageProgress==3)
	{
		if(stage3alpha<=150)
		{
			stage3alpha+=150/240;
		}
			bgX += 1;
			if (bgX >= 6000)
			{
				bgX = 0;
			}
			bgX2 += 1;
			if (bgX >= 6000)
			{
				bgX2 = 0;
			}
				bgrt += 1;
				if(bgrt > 512){bgrt = bgrt - 512;}
				if(bgrt <   0){bgrt = bgrt + 512;}
		yield;
	}
stage4bgalpha;
	while(StageProgress==4)
	{
			bgX += 1;
			if (bgX >= 6000)
			{
				bgX = 0;
			}
			bgX2 += 1;
			if (bgX >= 6000)
			{
				bgX2 = 0;
			}
				bgrt += 1;
				if(bgrt > 512){bgrt = bgrt - 512;}
				if(bgrt <   0){bgrt = bgrt + 512;}
		yield;
	}
	while(StageProgress==5)
	{
		if(stage5alpha1<=100)
		{
			stage5alpha1+=100/240;
		}
		if(stage5alpha2<=150)
		{
			stage5alpha2+=150/240;
		}
			bgX += 1;
			if (bgX >= 6000)
			{
				bgX = 0;
			}
			bgX2 += 1;
			if (bgX >= 6000)
			{
				bgX2 = 0;
			}
				bgrt += 1;
				if(bgrt > 512){bgrt = bgrt - 512;}
				if(bgrt <   0){bgrt = bgrt + 512;}
		yield;
	}
	while(StageProgress>=6)
	{
		if(stage6alpha1<=120)
		{
			stage6alpha1+=120/240;
		}
		if(stage6alpha2<=80)
		{
			stage6alpha2+=80/240;
		}
			bgX += 1;
			if (bgX >= 6000)
			{
				bgX = 0;
			}
			bgX2 += 1;
			if (bgX >= 6000)
			{
				bgX2 = 0;
			}
				bgrt += 1;
				if(bgrt > 512){bgrt = bgrt - 512;}
				if(bgrt <   0){bgrt = bgrt + 512;}
		yield;
	}
}

task stage4bgalpha//stage4の背景のα値を変更するタスク
{
loop(240)
{
	stage4alpha2+=150/240;
	yield;
}
loop(1500)
{
			if(stage4alpha2>0)
			{
			stage4alpha2-=0.1;
			}
yield;
}
wait(1260);
while(stage4alpha1<100)
{
stage4alpha1+=0.1;
yield;
}
}

task DeleteUsedFile//もう使わないファイルをメモリから削除
{
	DeleteGraphic(csd ~ "img\spellname.png");//もう使わないから破棄
	DeleteGraphic(imgBG);//もう使わないから破棄
	wait(10);
	DeleteSE(MenuSE[0]);//もう使わないから破棄
	DeleteSE(MenuSE[1]);//もう使わないから破棄
	wait(900);
	DeleteGraphic(imgMenuEffect);//もう使わないから破棄
}	
///////////////////////////////////////////////////////////////////////////////////////
////////////////////////////ステージエフェクト、残機調整部////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
task MenuEffect//タイトル画面の紅葉を表示する
{
let RotateAngle;
let Scale;
let Alpha;
let YRandamColor;
loop
{
if(StageState==Menu)
{
	RotateAngle=rand(2,5);
	Scale=rand(0.2,1);
	Alpha=rand(100,200);
	YRandamColor=rand(0,50);
	EffectMomiji(RotateAngle,Scale,Alpha,YRandamColor);
}
	wait(5);

	if(StageProgress>=2)
	{
		break;
	}
}
}

task EffectMomiji(RotateAngle,Scale,Alpha,YRandamColor)//紅葉の設定
{
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgMenuEffect);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -15, -15);
		ObjEffect_SetVertexXY(obj, 1, 15,  -15);
		ObjEffect_SetVertexXY(obj, 2, 15, 15);
		ObjEffect_SetVertexXY(obj, 3,  -15,  15);
		
		ObjEffect_SetVertexUV(obj, 0,  2,  24);
		ObjEffect_SetVertexUV(obj, 1,  32, 24);
		ObjEffect_SetVertexUV(obj, 2, 32,  55);
		ObjEffect_SetVertexUV(obj, 3, 2, 55);
		ObjEffect_SetLayer(obj,8);
		ObjEffect_SetScale(obj, Scale,Scale);


		ObjEffect_SetVertexColor(obj,0,Alpha,255,50+YRandamColor,50);
		ObjEffect_SetVertexColor(obj,1,Alpha,255,50+YRandamColor,50);
		ObjEffect_SetVertexColor(obj,2,Alpha,255,50+YRandamColor,50);
		ObjEffect_SetVertexColor(obj,3,Alpha,255,50+YRandamColor,50);
		
		let speed=rand(1,2);
		Obj_SetPosition(obj,rand(GetClipMinX-64,GetClipMaxX+256),GetClipMinY-16);
		Obj_SetSpeed(obj,speed);
		Obj_SetAngle(obj,rand(80,100));
		let Zangle=rand(0,360);
		let dir=rand_int(0,1)*2-1;
		while(!Obj_BeDeleted(obj))
		{
			ObjEffect_SetAngle(obj,0,0,Zangle);
			Zangle+=RotateAngle*dir;
			Obj_SetSpeed(obj,speed);
			yield;
			if(Obj_GetY(obj)>GetClipMaxY+128)
			{
				Obj_Delete(obj);
			}
			if(StageState!=Menu)
			{
				ObjEffect_SetVertexColor(obj,0,Alpha,255,50+YRandamColor,50);
				ObjEffect_SetVertexColor(obj,1,Alpha,255,50+YRandamColor,50);
				ObjEffect_SetVertexColor(obj,2,Alpha,255,50+YRandamColor,50);
				ObjEffect_SetVertexColor(obj,3,Alpha,255,50+YRandamColor,50);
				Alpha-=5;
			}
		}
}

task EnemyMagicCircle//敵スペルカード発動時のエフェクト
{
loop
{
if(OnEnemySpell==true)
{
PlaySE("seUseSpellCard.wav");
MagicCircleAppear1;
MagicCircleAppear2;
while(OnEnemySpell==true){yield}
}
yield;
}
}

task MagicCircleAppear1//魔方陣その１
{
		let scax=0.0;
		let scay=0.0;
		let angle=0;
		let Xangle=-90;
		let Yangle=-90;	
		let Zangle=0;
		let RotateAngle=3;
  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,GetEnemyX,GetEnemyY);
		ObjEffect_SetTexture(obj,csd~"img\circle.png");
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_SetScale(obj, scax,scay);
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -128, -128);
		ObjEffect_SetVertexXY(obj, 1,  128, -128);
		ObjEffect_SetVertexXY(obj, 2,  128,  128);
		ObjEffect_SetVertexXY(obj, 3, -128,  128);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  256, 0);
		ObjEffect_SetVertexUV(obj, 2, 256,  256);
		ObjEffect_SetVertexUV(obj, 3, 0, 256);

		ObjEffect_SetVertexColor(obj,0,100,255,250,250);
		ObjEffect_SetVertexColor(obj,1,100,255,250,250);
		ObjEffect_SetVertexColor(obj,2,100,255,250,250);
		ObjEffect_SetVertexColor(obj,3,100,255,250,250);
		loop(90)
		{
			ObjEffect_SetScale(obj, scax,scay);
			scax+=1/90;
			scay+=1/90;
			ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);
				Xangle+=1;
				Yangle+=1;
			Zangle+=RotateAngle;
			Obj_SetPosition(obj,GetEnemyX,GetEnemyY);	
			yield;
		}
		loop
		{
			ObjEffect_SetScale(obj, scax,scay);
			scax-=1/(50*60);
			scay-=1/(50*60);
			ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);
			Zangle+=RotateAngle;
			Obj_SetPosition(obj,GetEnemyX,GetEnemyY);		
			yield;
			if(GetEnemyLife<=0)
			{
				if(GetSpellCardBonusScore!=0)
				{
					loop(60)
					{
						ObjEffect_SetVertexColor(obj,0,150,255,255,255);
						ObjEffect_SetVertexColor(obj,1,150,255,255,255);
						ObjEffect_SetVertexColor(obj,2,150,255,255,255);
						ObjEffect_SetVertexColor(obj,3,150,255,255,255);
						ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);
						Zangle+=RotateAngle;
						Xangle+=1.5;
						ObjEffect_SetScale(obj, scax,scay);
						scax+=1/60;
						scay+=1/60;
						yield;
					}
					loop(30)
					{
						ObjEffect_SetVertexColor(obj,0,150,255,255,255);
						ObjEffect_SetVertexColor(obj,1,150,255,255,255);
						ObjEffect_SetVertexColor(obj,2,150,255,255,255);
						ObjEffect_SetVertexColor(obj,3,150,255,255,255);
						ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);
						Zangle-=RotateAngle*2;
						Xangle-=1.5*2;
						ObjEffect_SetScale(obj, scax,scay);
						Obj_SetPosition(obj,GetPlayerX,GetPlayerY);
						scax-=1/30;
						scay-=1/30;
						yield;
					}
					loop(30)
					{
						ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);
						Zangle-=RotateAngle*2;
						ObjEffect_SetScale(obj, scax,scay);
						Obj_SetPosition(obj,GetPlayerX,GetPlayerY);
						if(scax>0)
						{
							scax-=1/30;
							scay-=1/30;
						}
						yield;
					}
				}
				else
				{
					loop(60)
					{
						ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);
						Zangle+=RotateAngle;
						ObjEffect_SetScale(obj, scax,scay);
						yield;
						if(scax>0)
						{
							scax-=1/60;
							scay-=1/60;
						}
					}
				}
			Obj_Delete(obj);
			return;		
			}
		}
}

task MagicCircleAppear2//魔方陣その2
{
		let scax=0.0;
		let scay=0.0;
		let angle=0;
		let Xangle=-90;
		let Yangle=-90;	
		let Zangle=0;
		let RotateAngle=3;
  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,GetEnemyX,GetEnemyY);
		ObjEffect_SetTexture(obj,csd~"img\circle.png");
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_SetScale(obj, scax,scay);
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -128, -128);
		ObjEffect_SetVertexXY(obj, 1,  128, -128);
		ObjEffect_SetVertexXY(obj, 2,  128,  128);
		ObjEffect_SetVertexXY(obj, 3, -128,  128);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  256, 0);
		ObjEffect_SetVertexUV(obj, 2, 256,  256);
		ObjEffect_SetVertexUV(obj, 3, 0, 256);

		ObjEffect_SetVertexColor(obj,0,100,255,255,255);
		ObjEffect_SetVertexColor(obj,1,100,255,255,255);
		ObjEffect_SetVertexColor(obj,2,100,255,255,255);
		ObjEffect_SetVertexColor(obj,3,100,255,255,255);
		loop(90)
		{
			ObjEffect_SetScale(obj, scax,scay);
			scax+=1/90;
			scay+=1/90;
			ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);
				Xangle-=1;
				Yangle+=1;
			Zangle+=RotateAngle;
			Obj_SetPosition(obj,GetEnemyX,GetEnemyY);	
			yield;
		}
		loop
		{
			ObjEffect_SetScale(obj, scax,scay);
			scax-=1/(50*60);
			scay-=1/(50*60);
			ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);
			Zangle+=RotateAngle;
			Obj_SetPosition(obj,GetEnemyX,GetEnemyY);		
			yield;
			if(GetEnemyLife<=0)
			{
				if(GetSpellCardBonusScore!=0)
				{
					loop(60)
					{
						ObjEffect_SetVertexColor(obj,0,100,255,250,250);
						ObjEffect_SetVertexColor(obj,1,100,255,250,250);
						ObjEffect_SetVertexColor(obj,2,100,255,250,250);
						ObjEffect_SetVertexColor(obj,3,100,255,250,250);
						ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);
						Zangle+=RotateAngle;
						Yangle+=1.5;
						ObjEffect_SetScale(obj, scax,scay);
						scax+=1/60;
						scay+=1/60;
						yield;
					}
					loop(30)
					{
						ObjEffect_SetVertexColor(obj,0,150,255,255,255);
						ObjEffect_SetVertexColor(obj,1,150,255,255,255);
						ObjEffect_SetVertexColor(obj,2,150,255,255,255);
						ObjEffect_SetVertexColor(obj,3,150,255,255,255);
						ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);
						Zangle-=RotateAngle*2;
						Yangle-=1.5*2;
						ObjEffect_SetScale(obj, scax,scay);
						Obj_SetPosition(obj,GetPlayerX,GetPlayerY);
						scax-=1/30;
						scay-=1/30;
						yield;
					}
					loop(30)
					{
						ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);
						Zangle-=RotateAngle*2;
						ObjEffect_SetScale(obj, scax,scay);
						Obj_SetPosition(obj,GetPlayerX,GetPlayerY);
						if(scax>0)
						{
							scax-=1/30;
							scay-=1/30;
						}
						yield;
					}
				}
				else
				{
					loop(60)
					{
						ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);
						Zangle+=RotateAngle;
						ObjEffect_SetScale(obj, scax,scay);
						yield;
						if(scax>0)
						{
							scax-=1/60;
							scay-=1/60;
						}
					}
				}
			Obj_Delete(obj);
			return;		
			}
		}
}

task EnemyLifeDisplay//下部に敵のライフを表示
{
loop
{
if(IsBossExisting==true)
{
BossLifeBerDisplay;
BossLifeDisplay;
while(GetEnemyLife>0){yield}
}
yield;
}
}

task BossLifeBerDisplay//ライフバーの枠の設定
{
	let BossLifeMax=GetEnemyLife;

		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, csd ~ "img\ber.png");
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -71, -5);
		ObjEffect_SetVertexXY(obj, 1, 71,  -5);
		ObjEffect_SetVertexXY(obj, 2, 71, 5);
		ObjEffect_SetVertexXY(obj, 3,  -71,  5);
		
		ObjEffect_SetVertexUV(obj, 0,  6,  11);
		ObjEffect_SetVertexUV(obj, 1,  148, 11);
		ObjEffect_SetVertexUV(obj, 2, 148,  21);
		ObjEffect_SetVertexUV(obj, 3, 6, 21);
		ObjEffect_SetLayer(obj,8);
		ObjEffect_SetScale(obj, 2.5,0.8);
		Obj_SetPosition(obj,GetCenterX,GetClipMaxY+8);

		while(GetEnemyLife>0)
		{
			yield
		}
		Obj_Delete(obj);
}


task BossLifeDisplay//ライフバーのバー部分の設定
{
	let BossLifeMax=GetEnemyLife;
	let scale=2.5;

		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, csd ~ "img\ber.png");
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, 0, -3);
		ObjEffect_SetVertexXY(obj, 1, 142,  -3);
		ObjEffect_SetVertexXY(obj, 2, 142, 3);
		ObjEffect_SetVertexXY(obj, 3,  0,  3);
		
		ObjEffect_SetVertexUV(obj, 0,  6,  27);
		ObjEffect_SetVertexUV(obj, 1,  148, 27);
		ObjEffect_SetVertexUV(obj, 2, 148,  33);
		ObjEffect_SetVertexUV(obj, 3, 6, 33);
		ObjEffect_SetLayer(obj,8);
		ObjEffect_SetScale(obj, scale,0.8);

		ObjEffect_SetVertexColor(obj,0,150,255,255,255);
		ObjEffect_SetVertexColor(obj,1,150,255,255,255);
		ObjEffect_SetVertexColor(obj,2,150,255,255,255);
		ObjEffect_SetVertexColor(obj,3,150,255,255,255);

		Obj_SetPosition(obj,GetCenterX-177,GetClipMaxY+8);

		while(GetEnemyLife>0)
		{
			scale=2.5*GetEnemyLife/BossLifeMax;
			ObjEffect_SetScale(obj, scale,0.8);
			yield;
		}
		Obj_Delete(obj);
}


sub LifeAndBombDefine//初期の残機とボムを設定（専用自機だから別にいらないが）
{
	while(GetPlayerLife<3)
	{
		ExtendPlayer(1);
	}
	while(GetPlayerBomb<3)
	{
		AddBomb(1);
	}
	while(GetPlayerLife>3)
	{
		ExtendPlayer(-1);
	}
	while(GetPlayerBomb>3)
	{
		AddBomb(-1);
	}
}

sub StageTitleDisplay//メニュー画面の表示、SecretSpell部分でも呼び出して再起している。
{
			loop
			{
				alternative(StageState)	
				case(Menu)
				{
					TASK_MENU;
		 		}
				case(Exit)
				{
					break;
		 		}
				others{}
			yield;
			}

			ForbidShot(false);
			if(SelectedDifficult=="SecretSpell")
			{
				StageSecretSpell;
				while(SelectedDifficult=="SecretSpell" || StageState==Menu)
				{
					yield;
				}
			}
			ForbidBomb(false);
}

task ExtendSystem//エクステンドの設定
{
	if(SelectedDifficult!="Extra")
	{
	while(ScoreNumber2<25){yield;}
	ExtendPlayer(1);
	PlaySE("se\se1UP.wav");
	while(ScoreNumber2<50){yield;}
	ExtendPlayer(1);
	PlaySE("se\se1UP.wav");
	while(ScoreNumber2<100){yield;}
	ExtendPlayer(1);
	PlaySE("se\se1UP.wav");
	while(ScoreNumber2<200){yield;}
	ExtendPlayer(1);
	PlaySE("se\se1UP.wav");
	}
	else
	{
	while(ScoreNumber2<250){yield;}
	ExtendPlayer(1);
	PlaySE("se\se1UP.wav");
	while(ScoreNumber2<500){yield;}
	ExtendPlayer(1);
	PlaySE("se\se1UP.wav");
	while(ScoreNumber2<1000){yield;}
	ExtendPlayer(1);
	PlaySE("se\se1UP.wav");
	while(ScoreNumber2<2000){yield;}
	ExtendPlayer(1);
	PlaySE("se\se1UP.wav");
	while(ScoreNumber2<4000){yield;}
	ExtendPlayer(1);
	PlaySE("se\se1UP.wav");
	while(ScoreNumber2<7500){yield;}
	ExtendPlayer(1);
	PlaySE("se\se1UP.wav");
	while(ScoreNumber2<10000){yield;}
	ExtendPlayer(1);
	PlaySE("se\se1UP.wav");
	}
}

task StageCrear//StageClearと表示する
{
loop(240)
{
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgDifficult);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -34, -7);
		ObjEffect_SetVertexXY(obj, 1, 34,  -7);
		ObjEffect_SetVertexXY(obj, 2, 34, 7);
		ObjEffect_SetVertexXY(obj, 3,  -34,  7);
		
		ObjEffect_SetVertexUV(obj, 0,  5,  202);
		ObjEffect_SetVertexUV(obj, 1,  141, 202);
		ObjEffect_SetVertexUV(obj, 2, 141,  217);
		ObjEffect_SetVertexUV(obj, 3, 5, 217);
		ObjEffect_SetLayer(obj,8);
		ObjEffect_SetScale(obj, 3.5,2.5);
		Obj_SetPosition(obj,GetCenterX,GetClipMinY+128);

		yield;
		Obj_Delete(obj);
}
}

task NextStage//ClearBonusと表示する（紛らわしいが変更があったからこうなった）
{
loop(240)
{
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgDifficult);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -56, -8);
		ObjEffect_SetVertexXY(obj, 1, 56,  -8);
		ObjEffect_SetVertexXY(obj, 2, 56, 8);
		ObjEffect_SetVertexXY(obj, 3,  -56,  8);
		
		ObjEffect_SetVertexUV(obj, 0,  8,  182);
		ObjEffect_SetVertexUV(obj, 1,  119, 182);
		ObjEffect_SetVertexUV(obj, 2, 119,  197);
		ObjEffect_SetVertexUV(obj, 3, 8, 197);
		ObjEffect_SetLayer(obj,8);
		ObjEffect_SetScale(obj, 2.5,1.5);
		Obj_SetPosition(obj,GetCenterX,GetClipMinY+168);

		yield;
		Obj_Delete(obj);
}
}
////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////アイテム部////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
task CheckItem
{
let ItemCheck=0;//共通データの配列の長さをチェックする変数
let XY=[];//共通データの書き換えにワンクッション置くための変数
let ItemPerFrame=60;//１フレームあたりの最大アイテム生成数（処理落ち対策）
loop
{
	ItemCheck=length(GetCommonDataDefault("ItemXY",[]));//毎フレーム共通データの長さチェック
	if(ItemCheck>0)
	{//配列に中身がある（アイテム発生フラグ立っている）場合の処理
		loop(ItemPerFrame)
		{
			XY=GetCommonDataDefault("ItemXY",[]);//共通データ内容を変数に渡す
			Item(XY[0],XY[1],XY[2]);//アイテム生成。順番にX座標、Y座標、アイテムの種類
			loop(3)
			{
				XY=erase(XY, 0);
			}//生成したのでその要素を配列から削除
			if(length(XY)==0)
			{//削除後の配列が空になった場合
				SetCommonData("ItemXY",[]);//共通データを空にして
				break;//アイテム生成ループ脱出
		
			}
			else
			{
				SetCommonData("ItemXY",XY);
			}//配列が空でない場合共通データに変更後の配列を渡す
		}
	}
yield;
}
}

task Item(x,y,type)//typeごとにどういった挙動をするかを設定
{//アイテム設定
		let color="white";
		let dx=0;
		let dy=0;
		let dya=-2;
		let count=0;
		
		let scax=1;
		let scay=1;
		let speed=2;
		let angle=0;

		let collectline=160;
		let CollectOn=false;
		if(SelectedCharacter==DefinedPlayer3 || SelectedCharacter==DefinedPlayer4)
		{
			collectline=176;
		}
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgItem);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		//ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);

		if(type==1)
		{
			ObjEffect_SetVertexXY(obj, 0, -6, -6);
			ObjEffect_SetVertexXY(obj, 1, 6,  -6);
			ObjEffect_SetVertexXY(obj, 2, 6, 6);
			ObjEffect_SetVertexXY(obj, 3,  -6,  6);
		
			ObjEffect_SetVertexUV(obj, 0,  59,  21);
			ObjEffect_SetVertexUV(obj, 1,  71, 21);
			ObjEffect_SetVertexUV(obj, 2, 71,  33);
			ObjEffect_SetVertexUV(obj, 3, 59, 33);
		}
		if(type==2)
		{
			ObjEffect_SetVertexXY(obj, 0, -6, -6);
			ObjEffect_SetVertexXY(obj, 1, 6,  -6);
			ObjEffect_SetVertexXY(obj, 2, 6, 6);
			ObjEffect_SetVertexXY(obj, 3,  -6,  6);
		
			ObjEffect_SetVertexUV(obj, 0,  2,  21);
			ObjEffect_SetVertexUV(obj, 1,  14, 21);
			ObjEffect_SetVertexUV(obj, 2, 14,  33);
			ObjEffect_SetVertexUV(obj, 3, 2, 33);
		}
		if(type==3)
		{
			ObjEffect_SetTexture(obj, imgPlayerAndBomb);
			ObjEffect_SetVertexXY(obj, 0, -8, -8);
			ObjEffect_SetVertexXY(obj, 1, 8,  -8);
			ObjEffect_SetVertexXY(obj, 2, 8, 8);
			ObjEffect_SetVertexXY(obj, 3,  -8,  8);
		
			ObjEffect_SetVertexUV(obj, 0,  62,  320);
			ObjEffect_SetVertexUV(obj, 1,  77, 320);
			ObjEffect_SetVertexUV(obj, 2, 77,  335);
			ObjEffect_SetVertexUV(obj, 3, 62, 335);

			ObjEffect_SetVertexColor(obj,0,250,200,255,200);
			ObjEffect_SetVertexColor(obj,1,250,200,255,200);
			ObjEffect_SetVertexColor(obj,2,250,200,255,200);
			ObjEffect_SetVertexColor(obj,3,250,200,255,200);
			ObjEffect_SetScale(obj, 0.6,0.6);
		}
		if(type==4)
		{
			ObjEffect_SetVertexXY(obj, 0, -8, -8);
			ObjEffect_SetVertexXY(obj, 1, 8,  -8);
			ObjEffect_SetVertexXY(obj, 2, 8, 8);
			ObjEffect_SetVertexXY(obj, 3,  -8,  8);
		
			ObjEffect_SetVertexUV(obj, 0,  0,  0);
			ObjEffect_SetVertexUV(obj, 1,  16, 0);
			ObjEffect_SetVertexUV(obj, 2, 16,  16);
			ObjEffect_SetVertexUV(obj, 3, 0, 16);
		}
		if(type==5)
		{
			ObjEffect_SetVertexXY(obj, 0, -8, -8);
			ObjEffect_SetVertexXY(obj, 1, 8,  -8);
			ObjEffect_SetVertexXY(obj, 2, 8, 8);
			ObjEffect_SetVertexXY(obj, 3,  -8,  8);
		
			ObjEffect_SetVertexUV(obj, 0,  19,  0);
			ObjEffect_SetVertexUV(obj, 1,  35, 0);
			ObjEffect_SetVertexUV(obj, 2, 35,  16);
			ObjEffect_SetVertexUV(obj, 3, 19, 16);
		}

		if(type==11)
		{
			ObjEffect_SetTexture(obj, imgPlayerAndBomb);
			ObjEffect_SetVertexXY(obj, 0, -8, -8);
			ObjEffect_SetVertexXY(obj, 1, 8,  -8);
			ObjEffect_SetVertexXY(obj, 2, 8, 8);
			ObjEffect_SetVertexXY(obj, 3,  -8,  8);
		
			ObjEffect_SetVertexUV(obj, 0,  2,  320);
			ObjEffect_SetVertexUV(obj, 1,  17, 320);
			ObjEffect_SetVertexUV(obj, 2, 17,  335);
			ObjEffect_SetVertexUV(obj, 3, 2, 335);

			ObjEffect_SetVertexColor(obj,0,250,255,200,200);
			ObjEffect_SetVertexColor(obj,1,250,255,200,200);
			ObjEffect_SetVertexColor(obj,2,250,255,200,200);
			ObjEffect_SetVertexColor(obj,3,250,255,200,200);
			ObjEffect_SetScale(obj, 0.6,0.6);
		}
		if(type==12)
		{
			ObjEffect_SetTexture(obj, imgPlayerAndBomb);
			ObjEffect_SetVertexXY(obj, 0, -8, -8);
			ObjEffect_SetVertexXY(obj, 1, 8,  -8);
			ObjEffect_SetVertexXY(obj, 2, 8, 8);
			ObjEffect_SetVertexXY(obj, 3,  -8,  8);
		
			ObjEffect_SetVertexUV(obj, 0,  102,  320);
			ObjEffect_SetVertexUV(obj, 1,  117, 320);
			ObjEffect_SetVertexUV(obj, 2, 117,  335);
			ObjEffect_SetVertexUV(obj, 3, 102, 335);

			ObjEffect_SetVertexColor(obj,0,250,200,200,255);
			ObjEffect_SetVertexColor(obj,1,250,200,200,255);
			ObjEffect_SetVertexColor(obj,2,250,200,200,255);
			ObjEffect_SetVertexColor(obj,3,250,200,200,255);
			ObjEffect_SetScale(obj, 0.6,0.6);
		}
		if(type==13)
		{
			ObjEffect_SetTexture(obj, imgPlayerAndBomb);
			ObjEffect_SetVertexXY(obj, 0, -8, -8);
			ObjEffect_SetVertexXY(obj, 1, 8,  -8);
			ObjEffect_SetVertexXY(obj, 2, 8, 8);
			ObjEffect_SetVertexXY(obj, 3,  -8,  8);
		
			ObjEffect_SetVertexUV(obj, 0,  62,  320);
			ObjEffect_SetVertexUV(obj, 1,  77, 320);
			ObjEffect_SetVertexUV(obj, 2, 77,  335);
			ObjEffect_SetVertexUV(obj, 3, 62, 335);

			ObjEffect_SetVertexColor(obj,0,250,200,255,200);
			ObjEffect_SetVertexColor(obj,1,250,200,255,200);
			ObjEffect_SetVertexColor(obj,2,250,200,255,200);
			ObjEffect_SetVertexColor(obj,3,250,200,255,200);
			ObjEffect_SetScale(obj, 0.6,0.6);
		}
		Obj_SetAutoDelete(obj,false);
		ObjEffect_SetAngle(obj, 0,0,angle);
		//ObjEffect_SetScale(obj, scax,scay);
		Obj_SetPosition(obj,x,y);

		if((type==1 || type==2) && ItemPointerDrawing==1)
		{
			let objv = Obj_Create(OBJ_EFFECT);
			ObjEffect_SetTexture(objv, imgItem);
			ObjEffect_SetPrimitiveType(objv, PRIMITIVE_TRIANGLEFAN);
			//ObjEffect_SetRenderState(objv, ADD); 
			ObjEffect_CreateVertex(objv, 4);
			ObjEffect_SetVertexXY(objv, 0, -5, -4);
			ObjEffect_SetVertexXY(objv, 1, 5,  -4);
			ObjEffect_SetVertexXY(objv, 2, 5, 4);
			ObjEffect_SetVertexXY(objv, 3,  -5,  4);
		
			ObjEffect_SetVertexUV(objv, 0,  113,  2);
			ObjEffect_SetVertexUV(objv, 1,  124, 2);
			ObjEffect_SetVertexUV(objv, 2, 124,  10);
			ObjEffect_SetVertexUV(objv, 3, 113, 10);
			Obj_SetPosition(objv,x,GetClipMinY+8);
			ObjEffect_SetRenderState(objv,ALPHA);

			ItemAlpha(obj,objv,type);
		}

		while(!Obj_BeDeleted(obj))
		{
			Obj_SetPosition(obj,x+dx,y+dy);
			ObjEffect_SetAngle(obj, 0,0,angle);
			if(type==3){break;}
			if(type==11){break;}
			if(type==12){break;}
			if(type==13){break;}
			if(GetCommonDataDefault("KEKKAI",false)==true)
			{
				speed=7.0;
				color="yellow";
				CollectOn=true;
				break;
			}
			if(count<120)
			{
				dya+=4/120;
			}
			if(count<60)
			{
				angle+=30;
			}
			if(((Obj_GetX(obj)-GetPlayerX)^2+(Obj_GetY(obj)-GetPlayerY)^2)^0.5<20)
			{
				break;
			}
			if(((Obj_GetX(obj)-GetPlayerX)^2+(Obj_GetY(obj)-GetPlayerY)^2)^0.5<50 && GetPlayerMoveState==MOVE_SLOW)
			{
				break;
			}
			if(GetPlayerY<=collectline)
			{
				speed=7.0;
			//	color="yellow";
			//	CollectOn=true;//星仕様
				break;
			}
			if(Obj_GetY(obj)>=GetClipMaxY+16)
			{
				Obj_Delete(obj);			
			}
			dy=dy+dya;
			count++;
			yield;
		}
		ObjEffect_SetAngle(obj, 0,0,0);
		let StandardItemScore;
		let GetItemScore;
			if(type==3 || type==11 || type==12 || type==13)
			{
				speed=0.5;
				loop(15)
				{
				Obj_SetPosition(obj,Obj_GetX(obj)+speed*cos(-90),Obj_GetY(obj)+speed*sin(-90));
				wait(1);
				}
			}
		while(!Obj_BeDeleted(obj))
		{
			if(type==1 || type==2 ||type==4 || type==5)
			{
				speed+=0.2;
			}
			if(type==3 || type==11 || type==12 || type==13)
			{
				speed=8;
			}	
			let sangle=atan2(GetPlayerY-Obj_GetY(obj),GetPlayerX-Obj_GetX(obj));
			if(type==13)
			{
			Obj_SetAngle(obj,sangle);
			Obj_SetSpeed(obj,8);
			}
			else
			{
			Obj_SetAngle(obj,0);
			Obj_SetPosition(obj,Obj_GetX(obj)+speed*cos(sangle),Obj_GetY(obj)+speed*sin(sangle));
			}
			if(((Obj_GetX(obj)-GetPlayerX)^2+(Obj_GetY(obj)-GetPlayerY)^2)^0.5<10)
			{
				if(type==1)
				{
					let XY=GetCommonDataDefault("POWER",[]);//共通データ内容を変数に渡す
					XY=XY~[1];//
					SetCommonData("POWER",XY);//共通データに変更後の配列を渡す
					if(GetCommonDataDefault("POWERMAX",0)==5000)
					{
						StandardItemScore=GetCommonDataDefault("BONUSPOINT",0);
						GetItemScore=StandardItemScore/2;
						GetItemScore=(trunc(GetItemScore/10))*10;
						if(GetItemScoreDrawing==1)
						{
							DisPlayGetItemScore(Obj_GetX(obj),Obj_GetY(obj),GetItemScore,"yellow");
						}
						AddScore(GetItemScore);
					}
				}
				if(type==2)
				{
					StandardItemScore=GetCommonDataDefault("BONUSPOINT",0);
					if(GetPlayerY<=collectline || CollectOn==true)
					{
						color="yellow";
						GetItemScore=StandardItemScore;
					}
					else
					{
						GetItemScore=StandardItemScore*(0.75-0.5*GetPlayerY/(GetClipMaxY-16));
					}
					GetItemScore=(trunc(GetItemScore/10))*10;
					if(GetItemScoreDrawing==1)
					{
						DisPlayGetItemScore(Obj_GetX(obj),Obj_GetY(obj),GetItemScore,color);
					}
					AddScore(GetItemScore);
				}
				if(type==3)
				{
					let XY=GetCommonDataDefault("BONUSITEM",[]);//共通データ内容を変数に渡す
					XY=XY~[1];//
					SetCommonData("BONUSITEM",XY);//共通データに変更後の配列を渡す
				}
				if(type==4)
				{
					ExtendPlayer(1);
					PlaySE("se1UP.wav");
				}
				if(type==5)
				{
					AddBomb(1);
				}

				if(type==11)
				{
					let XY=GetCommonDataDefault("CHANGEPOWER",[]);//共通データ内容を変数に渡す
					XY=XY~[1];//
					SetCommonData("CHANGEPOWER",XY);//共通データに変更後の配列を渡す
				}
				if(type==12)
				{
					StandardItemScore=GetCommonDataDefault("BONUSPOINT",0);
					color="yellow";
					GetItemScore=StandardItemScore/5;
					GetItemScore=(trunc(GetItemScore/10))*10;
					if(GetItemScoreDrawing==1)
					{
						DisPlayGetItemScore(Obj_GetX(obj),Obj_GetY(obj),GetItemScore,color);
					}
					AddScore(GetItemScore);
				}
				if(type==13)
				{
					let XY=GetCommonDataDefault("BONUSITEM",[]);//共通データ内容を変数に渡す
					XY=XY~[1];//
					SetCommonData("BONUSITEM",XY);//共通データに変更後の配列を渡す
				}

				Obj_Delete(obj);
				PlaySE("seScore.wav");
			}
			yield;
		}
}

task ItemAlpha(obj,objv,type)//アイテムが画面上部に行ったとき、矢印のアルファ値変更
{
loop(180)
{
	if(type==1)
	{
		if(Obj_GetY(obj)<=GetClipMinY)
		{
			ObjEffect_SetVertexColor(objv,0,255,255,150,150);
			ObjEffect_SetVertexColor(objv,1,255,255,150,150);
			ObjEffect_SetVertexColor(objv,2,100,255,150,150);
			ObjEffect_SetVertexColor(objv,3,100,255,150,150);
		}
		else
		{
			ObjEffect_SetVertexColor(objv,0,0,255,200,200);
			ObjEffect_SetVertexColor(objv,1,0,255,200,200);
			ObjEffect_SetVertexColor(objv,2,0,255,200,200);
			ObjEffect_SetVertexColor(objv,3,0,255,200,200);
		}
	}
	else if(type==2)
	{
		if(Obj_GetY(obj)<=GetClipMinY)
		{
			ObjEffect_SetVertexColor(objv,0,255,150,150,255);
			ObjEffect_SetVertexColor(objv,1,255,150,150,255);
			ObjEffect_SetVertexColor(objv,2,255,150,150,255);
			ObjEffect_SetVertexColor(objv,3,255,150,150,255);
		}
		else
		{
			ObjEffect_SetVertexColor(objv,0,0,255,200,200);
			ObjEffect_SetVertexColor(objv,1,0,255,200,200);
			ObjEffect_SetVertexColor(objv,2,0,255,200,200);
			ObjEffect_SetVertexColor(objv,3,0,255,200,200);
		}
	}
	if(Obj_BeDeleted(obj))
	{
		break;
	}
yield;
}
Obj_Delete(objv);
}

task SCBItem//SCB獲得時にボーナスアイテムを出現させる
{
let DBonusItem;
alternative(SelectedDifficult)
case("Easy")
{
	DBonusItem=1;
}
case("Normal")
{
	DBonusItem=2;
}
case("Hard")
{
	DBonusItem=3;
}
case("Lunatic")
{
	DBonusItem=4;
}
case("Extra")
{
	DBonusItem=5;
}
let r=200;
	loop
	{
		while(!OnEnemySpell)
		{yield;}

		let SpellBonus;

		while(OnEnemySpell)
		{
			SpellBonus = GetSpellCardBonusScore();
			yield;
			if(GetEnemyLife() == 0){break;}
		}
		while(OnEnemySpell){yield;}
		wait(15);
		if(SpellBonus!=0)
		{
			ascent(let i in 0..10*DBonusItem+10*(StageProgress-1))
			{
				Item(GetPlayerX+r*cos(i*5),GetPlayerY+r*sin(i*5),3);
				Item(GetPlayerX+r*cos(72+i*5),GetPlayerY+r*sin(72+i*5),3);
				Item(GetPlayerX+r*cos(144+i*5),GetPlayerY+r*sin(144+i*5),3);
				Item(GetPlayerX+r*cos(216+i*5),GetPlayerY+r*sin(216+i*5),3);
				Item(GetPlayerX+r*cos(288+i*5),GetPlayerY+r*sin(288+i*5),3);
				Item(GetPlayerX+r*cos(-i*5),GetPlayerY+r*sin(-i*5),3);
				Item(GetPlayerX+r*cos(72-i*5),GetPlayerY+r*sin(72-i*5),3);
				Item(GetPlayerX+r*cos(144-i*5),GetPlayerY+r*sin(144-i*5),3);
				Item(GetPlayerX+r*cos(216-i*5),GetPlayerY+r*sin(216-i*5),3);
				Item(GetPlayerX+r*cos(288-i*5),GetPlayerY+r*sin(288-i*5),3);
				wait(1);
			}
		}
		wait(300);
	}
}

////////////////////////////////////////////////////////////////////////////////////////////
//////////////////時間計測、回数記録部,初期ボーナス部/////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
		task UpTimeCount//起動時間の計測
		{
			let UpTime=GetCommonDataDefaultEx(NsScore,NsUpTime,0);
			loop
			{
				UpTime++;
				SetCommonDataEx(NsScore,NsUpTime,UpTime);
				yield;
			}
		}

		task PlayTimeCount//プレイ時間の計測
		{
			let PlayTime=GetCommonDataDefaultEx(NsScore,NsPlayTime,0);
			loop
			{
				if(StageState!=Menu)
				{
				PlayTime++;
				}
				SetCommonDataEx(NsScore,NsPlayTime,PlayTime);
				yield;
			}
		}

		task PlayCharacterAndDifficult//プレイ回数を増やし初期霊点を決定する
		{
			alternative(SelectedDifficult)
			case("Easy")
			{
				alternative(SelectedCharacter)
				case(DefinedPlayer1)
				{
					let Frequency=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuAEasy,0);
					Frequency++;
					SetCommonDataEx(NsScore,NsFrequencyReimuAEasy,Frequency);		
				}
				case(DefinedPlayer2)
				{
					let Frequency=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuBEasy,0);
					Frequency++;
					SetCommonDataEx(NsScore,NsFrequencyReimuBEasy,Frequency);		
				}
				case(DefinedPlayer3)
				{
					let Frequency=GetCommonDataDefaultEx(NsScore,NsFrequencyMarisaAEasy,0);
					Frequency++;
					SetCommonDataEx(NsScore,NsFrequencyMarisaAEasy,Frequency);		
				}
				case(DefinedPlayer4)
				{
					let Frequency=GetCommonDataDefaultEx(NsScore,NsFrequencyMarisaBEasy,0);
					Frequency++;
					SetCommonDataEx(NsScore,NsFrequencyMarisaBEasy,Frequency);		
				}
				case(DefinedPlayer5)
				{
					let Frequency=GetCommonDataDefaultEx(NsScore,NsFrequencyOthersEasy,0);
					Frequency++;
					SetCommonDataEx(NsScore,NsFrequencyOthersEasy,Frequency);		
				}
			}
			case("Normal")
			{
				alternative(SelectedCharacter)
				case(DefinedPlayer1)
				{
					let Frequency=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuANormal,0);
					Frequency++;
					SetCommonDataEx(NsScore,NsFrequencyReimuANormal,Frequency);		
				}
				case(DefinedPlayer2)
				{
					let Frequency=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuBNormal,0);
					Frequency++;
					SetCommonDataEx(NsScore,NsFrequencyReimuBNormal,Frequency);		
				}
				case(DefinedPlayer3)
				{
					let Frequency=GetCommonDataDefaultEx(NsScore,NsFrequencyMarisaANormal,0);
					Frequency++;
					SetCommonDataEx(NsScore,NsFrequencyMarisaANormal,Frequency);		
				}
				case(DefinedPlayer4)
				{
					let Frequency=GetCommonDataDefaultEx(NsScore,NsFrequencyMarisaBNormal,0);
					Frequency++;
					SetCommonDataEx(NsScore,NsFrequencyMarisaBNormal,Frequency);		
				}
				case(DefinedPlayer5)
				{
					let Frequency=GetCommonDataDefaultEx(NsScore,NsFrequencyOthersNormal,0);
					Frequency++;
					SetCommonDataEx(NsScore,NsFrequencyOthersNormal,Frequency);		
				}
			}
			case("Hard")
			{
				alternative(SelectedCharacter)
				case(DefinedPlayer1)
				{
					let Frequency=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuAHard,0);
					Frequency++;
					SetCommonDataEx(NsScore,NsFrequencyReimuAHard,Frequency);		
				}
				case(DefinedPlayer2)
				{
					let Frequency=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuBHard,0);
					Frequency++;
					SetCommonDataEx(NsScore,NsFrequencyReimuBHard,Frequency);		
				}
				case(DefinedPlayer3)
				{
					let Frequency=GetCommonDataDefaultEx(NsScore,NsFrequencyMarisaAHard,0);
					Frequency++;
					SetCommonDataEx(NsScore,NsFrequencyMarisaAHard,Frequency);		
				}
				case(DefinedPlayer4)
				{
					let Frequency=GetCommonDataDefaultEx(NsScore,NsFrequencyMarisaBHard,0);
					Frequency++;
					SetCommonDataEx(NsScore,NsFrequencyMarisaBHard,Frequency);		
				}
				case(DefinedPlayer5)
				{
					let Frequency=GetCommonDataDefaultEx(NsScore,NsFrequencyOthersHard,0);
					Frequency++;
					SetCommonDataEx(NsScore,NsFrequencyOthersHard,Frequency);		
				}
			}
			case("Lunatic")
			{
				alternative(SelectedCharacter)
				case(DefinedPlayer1)
				{
					let Frequency=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuALunatic,0);
					Frequency++;
					SetCommonDataEx(NsScore,NsFrequencyReimuALunatic,Frequency);		
				}
				case(DefinedPlayer2)
				{
					let Frequency=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuBLunatic,0);
					Frequency++;
					SetCommonDataEx(NsScore,NsFrequencyReimuBLunatic,Frequency);		
				}
				case(DefinedPlayer3)
				{
					let Frequency=GetCommonDataDefaultEx(NsScore,NsFrequencyMarisaALunatic,0);
					Frequency++;
					SetCommonDataEx(NsScore,NsFrequencyMarisaALunatic,Frequency);		
				}
				case(DefinedPlayer4)
				{
					let Frequency=GetCommonDataDefaultEx(NsScore,NsFrequencyMarisaBLunatic,0);
					Frequency++;
					SetCommonDataEx(NsScore,NsFrequencyMarisaBLunatic,Frequency);		
				}
				case(DefinedPlayer5)
				{
					let Frequency=GetCommonDataDefaultEx(NsScore,NsFrequencyOthersLunatic,0);
					Frequency++;
					SetCommonDataEx(NsScore,NsFrequencyOthersLunatic,Frequency);		
				}
			}
			case("Extra")
			{
				alternative(SelectedCharacter)
				case(DefinedPlayer1)
				{
					let Frequency=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuAExtra,0);
					Frequency++;
					SetCommonDataEx(NsScore,NsFrequencyReimuAExtra,Frequency);		
				}
				case(DefinedPlayer2)
				{
					let Frequency=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuBExtra,0);
					Frequency++;
					SetCommonDataEx(NsScore,NsFrequencyReimuBExtra,Frequency);		
				}
				case(DefinedPlayer3)
				{
					let Frequency=GetCommonDataDefaultEx(NsScore,NsFrequencyMarisaAExtra,0);
					Frequency++;
					SetCommonDataEx(NsScore,NsFrequencyMarisaAExtra,Frequency);		
				}
				case(DefinedPlayer4)
				{
					let Frequency=GetCommonDataDefaultEx(NsScore,NsFrequencyMarisaBExtra,0);
					Frequency++;
					SetCommonDataEx(NsScore,NsFrequencyMarisaBExtra,Frequency);		
				}
				case(DefinedPlayer5)
				{
					let Frequency=GetCommonDataDefaultEx(NsScore,NsFrequencyOthersExtra,0);
					Frequency++;
					SetCommonDataEx(NsScore,NsFrequencyOthersExtra,Frequency);		
				}
			}
			SetCommonData("SELECTEDDIFFICULT",SelectedDifficult);//選択難易度を受け渡すため保存
			alternative(SelectedDifficult)
			case("Easy")
			{
				SetCommonData("BONUSPOINT",50000);
			}
			case("Normal")
			{
				SetCommonData("BONUSPOINT",50000);
			}
			case("Hard")
			{
				SetCommonData("BONUSPOINT",75000);
			}
			case("Lunatic")
			{
				SetCommonData("BONUSPOINT",100000);
			}
			case("Extra")
			{
				SetCommonData("BONUSPOINT",200000);
			}
		}
/////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////ステータス表示部//////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
task DifficultDisplay//難易度を表示
{
let num;
let dx;
	alternative(SelectedDifficult)
	case("Easy")
	{
		num=0;
		dx=24;
	}
	case("Normal")
	{
		num=1;
		dx=8;
	}
	case("Hard")
	{
		num=2;
		dx=24;
	}
	case("Lunatic")
	{
		num=3;
		dx=6;
	}
	case("Extra")
	{
		num=4;
		dx=16;
	}
	others
	{
		num=4;
		dx=0;
	}
loop
{
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgDifficult);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, 0, -7);
		ObjEffect_SetVertexXY(obj, 1, 88,  -7);
		ObjEffect_SetVertexXY(obj, 2, 88, 7);
		ObjEffect_SetVertexXY(obj, 3,  0,  7);
		
		ObjEffect_SetVertexUV(obj, 0,  5,  9+23*num);
		ObjEffect_SetVertexUV(obj, 1,  92, 9+23*num);
		ObjEffect_SetVertexUV(obj, 2, 92,  23+23*num);
		ObjEffect_SetVertexUV(obj, 3, 5, 23+23*num);
		ObjEffect_SetLayer(obj,8);
		Obj_SetPosition(obj,GetClipMaxX+64+dx,GetClipMinY+16);

		yield;
		Obj_Delete(obj);
}
}

task StatusDisplay//Hiscoreから霊点までの文字を表示
{
loop
{
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgDifficult);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, 0, -74);
		ObjEffect_SetVertexXY(obj, 1, 70,  -74);
		ObjEffect_SetVertexXY(obj, 2, 70, 74);
		ObjEffect_SetVertexXY(obj, 3,  0,  74);
		
		ObjEffect_SetVertexUV(obj, 0,  145,  8);
		ObjEffect_SetVertexUV(obj, 1,  215, 8);
		ObjEffect_SetVertexUV(obj, 2, 215,  156);
		ObjEffect_SetVertexUV(obj, 3, 145, 156);
		ObjEffect_SetLayer(obj,8);
		ObjEffect_SetScale(obj,1,1.2);
		Obj_SetPosition(obj,GetClipMaxX+10,GetClipMinY+120);

		yield;
		Obj_Delete(obj);
}
}

task PlayerAndBombDisplay//残機と残ボムを星で表示
{
let life;
let bomb;
loop
{
	life=GetPlayerLife-1;
	if(life>8)
	{
		life=8;
	}
	bomb=GetPlayerBomb;
	if(bomb>8)
	{
		bomb=8;
	}
	ascent(let i in 0..life)
	{
		DisPlayPlayerStar(i);
	}
	ascent(let i in 0..bomb)
	{
		DisPlayBombStar(i);
	}
	if(GetCommonDataDefault("BombBonus",0)/2>=1)//スペシャルボムの表示(ver1.50以降未使用）
	{
		ascent(let i in bomb..bomb+trunc(GetCommonDataDefault("BombBonus",0)/2))
		{
			DisPlaySPBombStar(i);
		}
	}
	if(GetCommonDataDefault("BombBonus",0)%2==1)//スペシャルボムの表示(ver1.50以降未使用）
	{
		DisPlayBombStarHalf(bomb+trunc(GetCommonDataDefault("BombBonus",0)/2));
	}
		
yield;
}
}

task DisPlayPlayerStar(i)//残機を表示
{
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,imgPlayerAndBomb);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ALPHA); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -8, -8);
		ObjEffect_SetVertexXY(obj, 1, 8,  -8);
		ObjEffect_SetVertexXY(obj, 2, 8, 8);
		ObjEffect_SetVertexXY(obj, 3,  -8,  8);
		
		ObjEffect_SetVertexUV(obj, 0,  2,  320);
		ObjEffect_SetVertexUV(obj, 1,  17, 320);
		ObjEffect_SetVertexUV(obj, 2, 17,  335);
		ObjEffect_SetVertexUV(obj, 3, 2, 335);
		ObjEffect_SetLayer(obj,8);
		ObjEffect_SetVertexColor(obj,0,255,255,200,200);
		ObjEffect_SetVertexColor(obj,1,255,255,200,200);
		ObjEffect_SetVertexColor(obj,2,255,255,200,200);
		ObjEffect_SetVertexColor(obj,3,255,255,200,200);
		ObjEffect_SetScale(obj,0.9,0.9);
		Obj_SetPosition(obj,GetClipMaxX+100+16*i,GetClipMinY+105);
		yield;
		Obj_Delete(obj);
}

task DisPlayBombStar(i)//残ボムを表示
{
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,imgPlayerAndBomb);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ALPHA); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -8, -8);
		ObjEffect_SetVertexXY(obj, 1, 8,  -8);
		ObjEffect_SetVertexXY(obj, 2, 8, 8);
		ObjEffect_SetVertexXY(obj, 3,  -8,  8);
		
		ObjEffect_SetVertexUV(obj, 0,  62,  320);
		ObjEffect_SetVertexUV(obj, 1,  77, 320);
		ObjEffect_SetVertexUV(obj, 2, 77,  335);
		ObjEffect_SetVertexUV(obj, 3, 62, 335);
		ObjEffect_SetLayer(obj,8);
		ObjEffect_SetVertexColor(obj,0,255,200,255,200);
		ObjEffect_SetVertexColor(obj,1,255,200,255,200);
		ObjEffect_SetVertexColor(obj,2,255,200,255,200);
		ObjEffect_SetVertexColor(obj,3,255,200,255,200);
		ObjEffect_SetScale(obj,0.9,0.9);
		Obj_SetPosition(obj,GetClipMaxX+100+16*i,GetClipMinY+132);
		yield;
		Obj_Delete(obj);
}

task DisPlaySPBombStar(i)//残スペシャルボムを表示
{
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,imgPlayerAndBomb);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ALPHA); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -8, -8);
		ObjEffect_SetVertexXY(obj, 1, 8,  -8);
		ObjEffect_SetVertexXY(obj, 2, 8, 8);
		ObjEffect_SetVertexXY(obj, 3,  -8,  8);
		
		ObjEffect_SetVertexUV(obj, 0,  42,  320);
		ObjEffect_SetVertexUV(obj, 1,  57, 320);
		ObjEffect_SetVertexUV(obj, 2, 57,  335);
		ObjEffect_SetVertexUV(obj, 3, 42, 335);
		ObjEffect_SetLayer(obj,8);
		ObjEffect_SetVertexColor(obj,0,255,255,255,200);
		ObjEffect_SetVertexColor(obj,1,255,255,255,200);
		ObjEffect_SetVertexColor(obj,2,255,255,255,200);
		ObjEffect_SetVertexColor(obj,3,255,255,255,200);
		ObjEffect_SetScale(obj,0.9,0.9);
		Obj_SetPosition(obj,GetClipMaxX+100+16*i,GetClipMinY+132);
		yield;
		Obj_Delete(obj);
}

task DisPlayBombStarHalf(i)//残スペシャルボム半個を表示
{
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,imgPlayerAndBomb);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ALPHA); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -4, -8);
		ObjEffect_SetVertexXY(obj, 1, 4,  -8);
		ObjEffect_SetVertexXY(obj, 2, 4, 8);
		ObjEffect_SetVertexXY(obj, 3,  -4,  8);
		
		ObjEffect_SetVertexUV(obj, 0,  42,  320);
		ObjEffect_SetVertexUV(obj, 1,  50, 320);
		ObjEffect_SetVertexUV(obj, 2, 50,  335);
		ObjEffect_SetVertexUV(obj, 3, 42, 335);
		ObjEffect_SetLayer(obj,8);
		ObjEffect_SetVertexColor(obj,0,255,255,255,200);
		ObjEffect_SetVertexColor(obj,1,255,255,255,200);
		ObjEffect_SetVertexColor(obj,2,255,255,255,200);
		ObjEffect_SetVertexColor(obj,3,255,255,255,200);
		ObjEffect_SetScale(obj,0.9,0.9);
		Obj_SetPosition(obj,GetClipMaxX+96+16*i,GetClipMinY+132);
		yield;
		Obj_Delete(obj);
}

task DisPlayScore//ハイスコアを呼び出し、ハイスコアと現スコアを表示
{
let EachHiScore=0;
let EachHiScore2=0;
	alternative(SelectedDifficult)
	case("Easy")
	{
		alternative(SelectedCharacter)
		case(DefinedPlayer1)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuAEasy[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuAEasy2[0],0);
		}
		case(DefinedPlayer2)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuBEasy[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuBEasy2[0],0);
		}
		case(DefinedPlayer3)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreMarisaAEasy[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreMarisaAEasy2[0],0);
		}
		case(DefinedPlayer4)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreMarisaBEasy[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreMarisaBEasy2[0],0);	
		}
		case(DefinedPlayer5)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreOthersEasy[0],0);	
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreOthersEasy2[0],0);
		}
	}
	case("Normal")
	{
		alternative(SelectedCharacter)
		case(DefinedPlayer1)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuANormal[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuANormal2[0],0);
		}
		case(DefinedPlayer2)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuBNormal[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuBNormal2[0],0);
		}
		case(DefinedPlayer3)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreMarisaANormal[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreMarisaANormal2[0],0);
		}
		case(DefinedPlayer4)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreMarisaBNormal[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreMarisaBNormal2[0],0);		
		}
		case(DefinedPlayer5)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreOthersNormal[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreOthersNormal2[0],0);		
		}
	}
	case("Hard")
	{
		alternative(SelectedCharacter)
		case(DefinedPlayer1)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuAHard[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuAHard2[0],0);
		}
		case(DefinedPlayer2)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuBHard[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuBHard2[0],0);
		}
		case(DefinedPlayer3)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreMarisaAHard[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreMarisaAHard2[0],0);
		}
		case(DefinedPlayer4)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreMarisaBHard[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreMarisaBHard2[0],0);
		}
		case(DefinedPlayer5)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreOthersHard[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreOthersHard2[0],0);
		}
	}
	case("Lunatic")
	{
		alternative(SelectedCharacter)
		case(DefinedPlayer1)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuALunatic[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuALunatic2[0],0);
		}
		case(DefinedPlayer2)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuBLunatic[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuBLunatic2[0],0);
		}
		case(DefinedPlayer3)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreMarisaALunatic[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreMarisaALunatic2[0],0);
		}
		case(DefinedPlayer4)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreMarisaBLunatic[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreMarisaBLunatic2[0],0);		
		}
		case(DefinedPlayer5)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreOthersLunatic[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreOthersLunatic2[0],0);		
		}
	}
	case("Extra")
	{
		alternative(SelectedCharacter)
		case(DefinedPlayer1)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuAExtra[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuAExtra2[0],0);
		}
		case(DefinedPlayer2)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuBExtra[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreReimuBExtra2[0],0);
		}
		case(DefinedPlayer3)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreMarisaAExtra[0],0);
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreMarisaAExtra2[0],0);
		}
		case(DefinedPlayer4)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreMarisaBExtra[0],0);	
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreMarisaBExtra2[0],0);	
		}
		case(DefinedPlayer5)
		{
			EachHiScore=GetCommonDataDefaultEx(NsScore,NsHiScoreOthersExtra[0],0);	
			EachHiScore2=GetCommonDataDefaultEx(NsScore,NsHiScoreOthersExtra2[0],0);		
		}
	}
CreateScore(EachHiScore,EachHiScore2);

/*旧スコア表示　２０億以上に対応できない
loop
{
if(GetScore>=EachHiScore)
{
	EachHiScore=GetScore;
}

	DisPlayNumber(GetClipMaxX+210,GetClipMinY+42,NumToString(EachHiScore),0);
	DisPlayNumber(GetClipMaxX+210,GetClipMinY+72,GetScore,0);

yield;
}
*/
}

function CreateScore(let EachHiScore,let EachHiScore2)//GetScore関数から二つにわけた変数に記録し擬似的に桁を増やしている
{
	continucount;
loop
{
	ScoreNumber1+=GetScore;
	AddScore(-GetScore);

	loop(2)
	{
		if(ScoreNumber1>=1000000)
		{
			ScoreNumber2+=1;
			ScoreNumber1-=1000000;
		}
	}

/*	if(ScoreNumber2>=EachHiScore2)
	{
		EachHiScore2=ScoreNumber2;
	}
	if(ScoreNumber2>=EachHiScore2 && ScoreNumber1>=EachHiScore)
	{
		EachHiScore=ScoreNumber1;
	}
*/
	if(EachHiScore2>ScoreNumber2)
	{
	DisPlayScoreNumber(GetClipMaxX+210,GetClipMinY+42,EachHiScore,EachHiScore2);
	DisPlayScoreNumber2(GetClipMaxX+138,GetClipMinY+42,EachHiScore2,0);
	}
	else
	{
	DisPlayScoreNumber(GetClipMaxX+210,GetClipMinY+42,ScoreNumber1,ScoreNumber2);
	DisPlayScoreNumber2(GetClipMaxX+138,GetClipMinY+42,ScoreNumber2,0);
	}

	DisPlayScoreNumber(GetClipMaxX+210,GetClipMinY+72,ScoreNumber1,ScoreNumber2);
	DisPlayScoreNumber2(GetClipMaxX+138,GetClipMinY+72,ScoreNumber2,0);
yield;
}
}

task continucount//コンテしたらスコアを0にする
{
	while(Continued==false)
	{
		yield;
	}
	ScoreNumber2=0;
	ScoreNumber1=0;
}

//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////インクルード部////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
#include_function ".\txt/stagedata.txt"
#include_function ".\txt/hiscore.txt"
#include_function ".\txt/MENU.txt"
#include_function ".\txt/MENUDRAW.txt"
#include_function ".\txt/SpellName.txt"
#include_function ".\stage1/STAGE1.txt"
#include_function ".\stage2/STAGE2.txt"
#include_function ".\stage3/STAGE3.txt"
#include_function ".\stage4/STAGE4.txt"
#include_function ".\stage5/STAGE5.txt"
#include_function ".\stage6/STAGE6.txt"
#include_function ".\secret/SecretSpell.txt"

}