if(time==0){
let xsize=640;
let ysize=480;
	PTBG=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(PTBG,320,240);
	ObjEffect_SetScale(PTBG,1,1);
	ObjEffect_SetLayer(PTBG,8); ObjEffect_SetTexture(PTBG,EFBG); ObjEffect_SetRenderState(PTBG,ALPHA);
	ObjEffect_SetPrimitiveType(PTBG,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(PTBG,4);
	ObjEffect_SetVertexXY(PTBG,0,-(xsize/2),-(ysize/2)); ObjEffect_SetVertexUV(PTBG,0,0,0);
	ObjEffect_SetVertexXY(PTBG,1,(xsize/2),-(ysize/2)); ObjEffect_SetVertexUV(PTBG,1,xsize,0);
	ObjEffect_SetVertexXY(PTBG,2,-xsize/2,ysize/2); ObjEffect_SetVertexUV(PTBG,2,0,ysize);
	ObjEffect_SetVertexXY(PTBG,3,(xsize/2),ysize/2); ObjEffect_SetVertexUV(PTBG,3,xsize,ysize);
	ObjEffect_SetVertexColor(PTBG,0,255,255,255,255); ObjEffect_SetVertexColor(PTBG,1,255,255,255,255);
	ObjEffect_SetVertexColor(PTBG,2,255,255,255,255); ObjEffect_SetVertexColor(PTBG,3,255,255,255,255);

	PTback=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(PTback,320,240);
	ObjEffect_SetScale(PTback,1,1);
	ObjEffect_SetLayer(PTback,8); ObjEffect_SetTexture(PTback,EFback); ObjEffect_SetRenderState(PTback,ALPHA);
	ObjEffect_SetPrimitiveType(PTback,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(PTback,4);
	ObjEffect_SetVertexXY(PTback,0,-(xsize/2),-(ysize/2)); ObjEffect_SetVertexUV(PTback,0,0,0);
	ObjEffect_SetVertexXY(PTback,1,(xsize/2),-(ysize/2)); ObjEffect_SetVertexUV(PTback,1,xsize,0);
	ObjEffect_SetVertexXY(PTback,2,-xsize/2,ysize/2); ObjEffect_SetVertexUV(PTback,2,0,ysize);
	ObjEffect_SetVertexXY(PTback,3,(xsize/2),ysize/2); ObjEffect_SetVertexUV(PTback,3,xsize,ysize);
	ObjEffect_SetVertexColor(PTback,0,255,255,255,255); ObjEffect_SetVertexColor(PTback,1,255,255,255,255);
	ObjEffect_SetVertexColor(PTback,2,255,255,255,255); ObjEffect_SetVertexColor(PTback,3,255,255,255,255);

	PTdata=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(PTdata,320,240);
	ObjEffect_SetScale(PTdata,1,1);
	ObjEffect_SetLayer(PTdata,8); ObjEffect_SetTexture(PTdata,EFdata); ObjEffect_SetRenderState(PTdata,ALPHA);
	ObjEffect_SetPrimitiveType(PTdata,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(PTdata,4);
	ObjEffect_SetVertexXY(PTdata,0,-(xsize/2),-(ysize/2)); ObjEffect_SetVertexUV(PTdata,0,0,0);
	ObjEffect_SetVertexXY(PTdata,1,(xsize/2),-(ysize/2)); ObjEffect_SetVertexUV(PTdata,1,xsize,0);
	ObjEffect_SetVertexXY(PTdata,2,-xsize/2,ysize/2); ObjEffect_SetVertexUV(PTdata,2,0,ysize);
	ObjEffect_SetVertexXY(PTdata,3,(xsize/2),ysize/2); ObjEffect_SetVertexUV(PTdata,3,xsize,ysize);
	ObjEffect_SetVertexColor(PTdata,0,255,255,255,255); ObjEffect_SetVertexColor(PTdata,1,255,255,255,255);
	ObjEffect_SetVertexColor(PTdata,2,255,255,255,255); ObjEffect_SetVertexColor(PTdata,3,255,255,255,255);

let xsize=450;
let ysize=450;
	PTcircle=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(PTcircle,320,240);
	ObjEffect_SetScale(PTcircle,1,1);
	ObjEffect_SetLayer(PTcircle,8); ObjEffect_SetTexture(PTcircle,EFspellcircle); ObjEffect_SetRenderState(PTcircle,ALPHA);
	ObjEffect_SetPrimitiveType(PTcircle,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(PTcircle,4);
	ObjEffect_SetVertexXY(PTcircle,0,-(xsize/2),-(ysize/2)); ObjEffect_SetVertexUV(PTcircle,0,0,0);
	ObjEffect_SetVertexXY(PTcircle,1,(xsize/2),-(ysize/2)); ObjEffect_SetVertexUV(PTcircle,1,xsize,0);
	ObjEffect_SetVertexXY(PTcircle,2,-xsize/2,ysize/2); ObjEffect_SetVertexUV(PTcircle,2,0,ysize);
	ObjEffect_SetVertexXY(PTcircle,3,(xsize/2),ysize/2); ObjEffect_SetVertexUV(PTcircle,3,xsize,ysize);
	ObjEffect_SetVertexColor(PTcircle,0,255,255,255,255); ObjEffect_SetVertexColor(PTcircle,1,255,255,255,255);
	ObjEffect_SetVertexColor(PTcircle,2,255,255,255,255); ObjEffect_SetVertexColor(PTcircle,3,255,255,255,255);

	PTarrow1=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(PTarrow1,320+44,240-10);
	ObjEffect_SetScale(PTarrow1,1,1);
	ObjEffect_SetAngle(PTarrow1,0,0,162);
	ObjEffect_SetLayer(PTarrow1,8); ObjEffect_SetTexture(PTarrow1,EFweakness); ObjEffect_SetRenderState(PTarrow1,ALPHA);
	ObjEffect_SetPrimitiveType(PTarrow1,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(PTarrow1,8);
	ObjEffect_SetVertexXY(PTarrow1,0,-16,-100); ObjEffect_SetVertexXY(PTarrow1,1,16,-100);
	ObjEffect_SetVertexXY(PTarrow1,2,-16,-70); ObjEffect_SetVertexXY(PTarrow1,3,16,-70);
	ObjEffect_SetVertexXY(PTarrow1,4,-16,70); ObjEffect_SetVertexXY(PTarrow1,5,16,70);
	ObjEffect_SetVertexXY(PTarrow1,6,-16,100); ObjEffect_SetVertexXY(PTarrow1,7,16,100);
	ObjEffect_SetVertexUV(PTarrow1,0,0,0+PTarrowscroll); ObjEffect_SetVertexUV(PTarrow1,1,38,0+PTarrowscroll);
	ObjEffect_SetVertexUV(PTarrow1,2,0,30+PTarrowscroll); ObjEffect_SetVertexUV(PTarrow1,3,38,30+PTarrowscroll);
	ObjEffect_SetVertexUV(PTarrow1,4,0,170+PTarrowscroll); ObjEffect_SetVertexUV(PTarrow1,5,38,170+PTarrowscroll);
	ObjEffect_SetVertexUV(PTarrow1,6,0,200+PTarrowscroll); ObjEffect_SetVertexUV(PTarrow1,7,38,200+PTarrowscroll);
	ObjEffect_SetVertexColor(PTarrow1,0,0,0,255,0); ObjEffect_SetVertexColor(PTarrow1,1,0,0,255,0);
	ObjEffect_SetVertexColor(PTarrow1,2,PTarrowfade,0,255,0); ObjEffect_SetVertexColor(PTarrow1,3,PTarrowfade,0,255,0);
	ObjEffect_SetVertexColor(PTarrow1,4,PTarrowfade,0,255,0); ObjEffect_SetVertexColor(PTarrow1,5,PTarrowfade,0,255,0);
	ObjEffect_SetVertexColor(PTarrow1,6,0,0,255,0); ObjEffect_SetVertexColor(PTarrow1,7,0,0,255,0);

	PTarrow2=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(PTarrow2,320-44,240-10);
	ObjEffect_SetScale(PTarrow2,1,1);
	ObjEffect_SetAngle(PTarrow2,0,0,18);
	ObjEffect_SetLayer(PTarrow2,8); ObjEffect_SetTexture(PTarrow2,EFweakness); ObjEffect_SetRenderState(PTarrow2,ALPHA);
	ObjEffect_SetPrimitiveType(PTarrow2,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(PTarrow2,8);
	ObjEffect_SetVertexXY(PTarrow2,0,-16,-100); ObjEffect_SetVertexXY(PTarrow2,1,16,-100);
	ObjEffect_SetVertexXY(PTarrow2,2,-16,-70); ObjEffect_SetVertexXY(PTarrow2,3,16,-70);
	ObjEffect_SetVertexXY(PTarrow2,4,-16,70); ObjEffect_SetVertexXY(PTarrow2,5,16,70);
	ObjEffect_SetVertexXY(PTarrow2,6,-16,100); ObjEffect_SetVertexXY(PTarrow2,7,16,100);
	ObjEffect_SetVertexUV(PTarrow2,0,0,0+PTarrowscroll); ObjEffect_SetVertexUV(PTarrow2,1,38,0+PTarrowscroll);
	ObjEffect_SetVertexUV(PTarrow2,2,0,30+PTarrowscroll); ObjEffect_SetVertexUV(PTarrow2,3,38,30+PTarrowscroll);
	ObjEffect_SetVertexUV(PTarrow2,4,0,170+PTarrowscroll); ObjEffect_SetVertexUV(PTarrow2,5,38,170+PTarrowscroll);
	ObjEffect_SetVertexUV(PTarrow2,6,0,200+PTarrowscroll); ObjEffect_SetVertexUV(PTarrow2,7,38,200+PTarrowscroll);
	ObjEffect_SetVertexColor(PTarrow2,0,0,255,0,0); ObjEffect_SetVertexColor(PTarrow2,1,0,255,0,0);
	ObjEffect_SetVertexColor(PTarrow2,2,PTarrowfade,255,0,0); ObjEffect_SetVertexColor(PTarrow2,3,PTarrowfade,255,0,0);
	ObjEffect_SetVertexColor(PTarrow2,4,PTarrowfade,255,0,0); ObjEffect_SetVertexColor(PTarrow2,5,PTarrowfade,255,0,0);
	ObjEffect_SetVertexColor(PTarrow2,6,0,255,0,0); ObjEffect_SetVertexColor(PTarrow2,7,0,255,0,0);
}

if(GetKeyState(VK_RIGHT)==KEY_PUSH && PTspintime<=0){ PTspin=-1; PTspintime=20; PTspinangle=0; PTselection++; PTarrowfade=0; PlaySE(SEmenumove2); }
if(GetKeyState(VK_LEFT)==KEY_PUSH && PTspintime<=0){ PTspin=1; PTspintime=20; PTspinangle=0; PTselection--; PTarrowfade=0; PlaySE(SEmenumove2); }
if(PTselection<1){ PTselection=5; }
if(PTselection>5){ PTselection=1; }

if(PTspin==-1 && PTspintime>0){ PTspinangle+=90/20; }
if(PTspin==1 && PTspintime>0){ PTspinangle-=90/20; }
if(PTspintime>-1){ PTspintime--; }
if(PTspintime==0 && PTspin==-1){ PTangle+=72; PTspinangle=0; PTspin=0; }
if(PTspintime==0 && PTspin==1){ PTangle-=72; PTspinangle=0; PTspin=0; }

ObjEffect_SetAngle(PTcircle,0,0,PTangle+72*sin(PTspinangle));

	ObjEffect_SetVertexUV(PTarrow1,0,0,0+PTarrowscroll); ObjEffect_SetVertexUV(PTarrow1,1,38,0+PTarrowscroll);
	ObjEffect_SetVertexUV(PTarrow1,2,0,30+PTarrowscroll); ObjEffect_SetVertexUV(PTarrow1,3,38,30+PTarrowscroll);
	ObjEffect_SetVertexUV(PTarrow1,4,0,170+PTarrowscroll); ObjEffect_SetVertexUV(PTarrow1,5,38,170+PTarrowscroll);
	ObjEffect_SetVertexUV(PTarrow1,6,0,200+PTarrowscroll); ObjEffect_SetVertexUV(PTarrow1,7,38,200+PTarrowscroll);
	ObjEffect_SetVertexColor(PTarrow1,0,0,0,255,0); ObjEffect_SetVertexColor(PTarrow1,1,0,0,255,0);
	ObjEffect_SetVertexColor(PTarrow1,2,PTarrowfade,0,255,0); ObjEffect_SetVertexColor(PTarrow1,3,PTarrowfade,0,255,0);
	ObjEffect_SetVertexColor(PTarrow1,4,PTarrowfade,0,255,0); ObjEffect_SetVertexColor(PTarrow1,5,PTarrowfade,0,255,0);
	ObjEffect_SetVertexColor(PTarrow1,6,0,0,255,0); ObjEffect_SetVertexColor(PTarrow1,7,0,0,255,0);

	ObjEffect_SetVertexUV(PTarrow2,0,0,0+PTarrowscroll); ObjEffect_SetVertexUV(PTarrow2,1,38,0+PTarrowscroll);
	ObjEffect_SetVertexUV(PTarrow2,2,0,30+PTarrowscroll); ObjEffect_SetVertexUV(PTarrow2,3,38,30+PTarrowscroll);
	ObjEffect_SetVertexUV(PTarrow2,4,0,170+PTarrowscroll); ObjEffect_SetVertexUV(PTarrow2,5,38,170+PTarrowscroll);
	ObjEffect_SetVertexUV(PTarrow2,6,0,200+PTarrowscroll); ObjEffect_SetVertexUV(PTarrow2,7,38,200+PTarrowscroll);
	ObjEffect_SetVertexColor(PTarrow2,0,0,255,0,0); ObjEffect_SetVertexColor(PTarrow2,1,0,255,0,0);
	ObjEffect_SetVertexColor(PTarrow2,2,PTarrowfade,255,0,0); ObjEffect_SetVertexColor(PTarrow2,3,PTarrowfade,255,0,0);
	ObjEffect_SetVertexColor(PTarrow2,4,PTarrowfade,255,0,0); ObjEffect_SetVertexColor(PTarrow2,5,PTarrowfade,255,0,0);
	ObjEffect_SetVertexColor(PTarrow2,6,0,255,0,0); ObjEffect_SetVertexColor(PTarrow2,7,0,255,0,0);

if(PTspin==0 && PTarrowfade<255){ PTarrowfade+=255/20; }
PTarrowscroll++;


if(GetKeyState(VK_SHOT)==KEY_PUSH && PTspintime<=0 && time>0){ 
	if(PTselection==1){ SetCommonData("PlayerType",1); }
	if(PTselection==2){ SetCommonData("PlayerType",5); }
	if(PTselection==3){ SetCommonData("PlayerType",4); }
	if(PTselection==4){ SetCommonData("PlayerType",3); }
	if(PTselection==5){ SetCommonData("PlayerType",2); }
	SetCommonData("ResetPlayer",1);
	PlaySE(SEmenuselect1);
}


if(PTselection==1){
	EFdata=("\script\Images\Menu\ElementsFire.png");
	ObjEffect_SetTexture(PTdata,EFdata);
}
if(PTselection==2){
	EFdata=("\script\Images\Menu\ElementsWater.png");
	ObjEffect_SetTexture(PTdata,EFdata);
}
if(PTselection==3){
	EFdata=("\script\Images\Menu\ElementsEarth.png");
	ObjEffect_SetTexture(PTdata,EFdata);
}
if(PTselection==4){
	EFdata=("\script\Images\Menu\ElementsWood.png");
	ObjEffect_SetTexture(PTdata,EFdata);
}
if(PTselection==5){
	EFdata=("\script\Images\Menu\ElementsMetal.png");
	ObjEffect_SetTexture(PTdata,EFdata);
}

if(GetKeyState(VK_SHOT)==KEY_PUSH && MAphase==2 && MAselection==1 && time>0){ mainmenu=0; SetCommonData("NextStage",1); time=0; frame=0; }
if(GetKeyState(VK_SHOT)==KEY_PUSH && MAphase==1 && MAselection==2 && time>0){ mainmenu=0; SetCommonData("NextStage",7); time=0; frame=0; }
if(GetKeyState(VK_SHOT)==KEY_PUSH && MAphase==1 && MAselection==3 && time>0){ mainmenu=0; SetCommonData("NextStage",8); time=0; frame=0; }
if(GetKeyState(VK_SHOT)==KEY_PUSH && MAphase==3 && time>0){
	mainmenu=0; stage=MAselection3; time=0; frame=0;
	if(MAselection3==1 || MAselection==8){ SetCommonData("Power",0); }
	if(MAselection3==2){ SetCommonData("Power",90); }
	if(MAselection3>=3 && MAselection3<=6){ SetCommonData("Power",160); }
	if(MAselection3==7){ SetCommonData("Power",70); }
}
if(GetKeyState(VK_SHOT)==KEY_PUSH && MAphase==1 && MAselection==4 && time>0){
	SetCommonData("BackToSpellcardPractise",0);
	mainmenu=3;
	time=0;
	frame=0;
}

if(GetKeyState(VK_BOMB)==KEY_PUSH && time>0){
	mainmenu=1;
	time=-1;
	frame=-1;
	PlaySE(SEmenucancel1);
}

SetPlayerX(cx);
SetPlayerY(400);
SetCommonData("InEvent",1);

if(mainmenu!=2){
	Obj_Delete(PTarrow1);
	Obj_Delete(PTarrow2);
	Obj_Delete(PTcircle);
	Obj_Delete(PTBG);
	Obj_Delete(PTback);
	Obj_Delete(PTdata);
	
	SetCommonData("BlackScreenFade",0);
}