//オプションの移動と描画、パワー整数値の更新もする
let OpangleT = -90;
let OpangleT2 = -90;
task OptionMove
{//Power1~4までのオプション位置


let LowOpX_P1=[0,0,0,0,0,0];
let LowOpY_P1=[0,0,0,0,0,0];
let HiOpX_P1=[0,0,0,0,0,0];
let HiOpY_P1=[0,0,0,0,0,0];

let LowOpX_P2=[0,0,0,0,0,0];
let LowOpY_P2=[0,0,0,0,0,0];
let HiOpX_P2=[0,0,0,0,0,0];
let HiOpY_P2=[0,0,0,0,0,0];

let LowOpX_P3=[0,0,0,0,0,0];
let LowOpY_P3=[0,0,0,0,0,0];
let HiOpX_P3=[0,0,0,0,0,0];
let HiOpY_P3=[0,0,0,0,0,0];

let LowOpX_P4=[0,0,0,0,0,0];
let LowOpY_P4=[0,0,0,0,0,0];
let HiOpX_P4=[0,0,0,0,0,0];
let HiOpY_P4=[0,0,0,0,0,0];

let LowOpX_P5=[0,0,0,0,0,0];
let LowOpY_P5=[0,0,0,0,0,0];
let HiOpX_P5=[0,0,0,0,0,0];
let HiOpY_P5=[0,0,0,0,0,0];

let LowOpX=[LowOpX_P1,LowOpX_P2,LowOpX_P3,LowOpX_P4,LowOpX_P5];
let LowOpY=[LowOpY_P1,LowOpY_P2,LowOpY_P3,LowOpY_P4,LowOpY_P5];
let HiOpX=[HiOpX_P1,HiOpX_P2,HiOpX_P3,HiOpX_P4,HiOpX_P5];
let HiOpY=[HiOpY_P1,HiOpY_P2,HiOpY_P3,HiOpY_P4,HiOpY_P5];
let objcount=0;
let LowCount=0;
let D_OptionX=[0,0,0,0,0,0];
let D_OptionY=[0,0,0,0,0,0];
let ARHG = (GetScreenWidth/2)-32;
let URHG = (GetScreenHeight/2)-32;
let XXX;
let YYY;
loop
{
	ascent(i in 0..6)
	{
		if(GetVirtualKeyState(VK_SLOWMOVE) == KEY_PUSH || GetVirtualKeyState(VK_SLOWMOVE) == KEY_HOLD)
		{
			if(PlayerType==1)
			{
				D_OptionX[i]=GetPlayerX+LowOpX[PlayerPower_Int-1][i];
				D_OptionY[i]=GetPlayerY+LowOpY[PlayerPower_Int-1][i];
			}
			else
			{
				D_OptionX[i]=GetPlayerX+LowOpX[PlayerPower_Int-1][i];
				D_OptionY[i]=GetPlayerY+LowOpY[PlayerPower_Int-1][i]-20;
			}
		}
		else
		{
			if(PlayerType==1)
			{
				D_OptionX[i]=GetPlayerX+HiOpX[PlayerPower_Int-1][i];
				D_OptionY[i]=GetPlayerY+HiOpY[PlayerPower_Int-1][i];
			}
			else
			{
				D_OptionX[i]=GetPlayerX+HiOpX[PlayerPower_Int-1][i];
				D_OptionY[i]=GetPlayerY+HiOpY[PlayerPower_Int-1][i]-30;
			}
		
		}
		OptionX[i]=OptionX[i]*0.70+D_OptionX[i]*0.30;
		OptionY[i]=OptionY[i]*0.70+D_OptionY[i]*0.30;
	}
	if(PlayerType==1)
	{
		LowOpX_P4=[25*cos(OpangleT),-25*cos(OpangleT2),0,0,0,0];
		LowOpY_P4=[20*sin(OpangleT*3),20*sin(OpangleT2*3),0,0,0,0];

		HiOpX_P4=[50*cos(OpangleT)+20,-50*cos(OpangleT2)-20,0,0,0,0];
		HiOpY_P4=[20*sin(OpangleT*3),20*sin(OpangleT2*3),0,0,0,0];
		OpangleT+=1;
		OpangleT2+=1;
	}
	else
	{
		LowOpX_P4=[30*cos(OpangleT+0),30*cos(OpangleT+60),30*cos(OpangleT+120),30*cos(OpangleT+180),30*cos(OpangleT+240),30*cos(OpangleT+300)];
		LowOpY_P4=[5*sin(OpangleT+0),5*sin(OpangleT+60),5*sin(OpangleT+120),5*sin(OpangleT+180),5*sin(OpangleT+240),5*sin(OpangleT+300)];

		HiOpX_P4=[60*cos(OpangleT+0),60*cos(OpangleT+60),60*cos(OpangleT+120),60*cos(OpangleT+180),60*cos(OpangleT+240),60*cos(OpangleT+300)];
		HiOpY_P4=[10*sin(OpangleT+0),10*sin(OpangleT+60),10*sin(OpangleT+120),10*sin(OpangleT+180),10*sin(OpangleT+240),10*sin(OpangleT+300)];
		OpangleT+=4;
		OpangleT2+=4;
	}
	HiOpX=[HiOpX_P1,HiOpX_P2,HiOpX_P3,HiOpX_P4,HiOpX_P4,HiOpX_P5];
	HiOpY=[HiOpY_P1,HiOpY_P2,HiOpY_P3,HiOpY_P4,HiOpY_P4,HiOpY_P5];
	LowOpX=[LowOpX_P1,LowOpX_P2,LowOpX_P3,LowOpX_P4,LowOpX_P4,LowOpX_P5];
	LowOpY=[LowOpY_P1,LowOpY_P2,LowOpY_P3,LowOpY_P4,LowOpY_P4,LowOpX_P5];
	
	objcount+=0.5;
	yield;
}
}

task TRenderOption
{
	let CurrentPower;
	let tt = 2;

	CurrentPower=PlayerPower_Int;
	loop
	{
		DrawOption(0,1);
		DrawOption(1,1);
		while(PlayerType==1){yield;}
		DrawOption(0,-1);
		DrawOption(2,-1);
		DrawOption(4,-1);
		
		DrawOption(1,-1);
		DrawOption(3,-1);
		DrawOption(5,-1);
		while(PlayerType==-1){yield;}
	}


	task DrawOption(num,stim)
	{
		let obj = ObjPrim_Create(OBJ_SPRITE_2D);
		objOption=objOption~[obj];
		ObjPrim_SetTexture(obj, IMG_OPTION);	
		Obj_SetRenderPriorityI(obj,43);
		let Zangle=0;
		ObjSprite2D_SetSourceRect(obj, 0, 0, (GetTextureWidth(IMG_OPTION)/8), (GetTextureHeight(IMG_OPTION)));
		ObjSprite2D_SetDestCenter(obj);
		let scale=1;
		//ObjRender_SetBlendType(obj, BLEND_ADD_RGB);


		ObjRender_SetBlendType(obj, BLEND_ALPHA);
		let DownCount=0;
		let t = 0;
		while(PlayerType==stim)
		{

			ObjSprite2D_SetSourceRect(obj, 0+(GetTextureWidth(IMG_OPTION)/8)*floor((t%16)), 0, (GetTextureWidth(IMG_OPTION)/8)+(GetTextureWidth(IMG_OPTION)/8)*floor((t%16)), (GetTextureHeight(IMG_OPTION)));
			t+=0.4;
			if(PlayerType==1)
			{
				ObjRender_SetAngleZ(obj,ObjRender_GetAngleZ(obj)+12.42);
			}
			else
			{
				ObjRender_SetAngleZ(obj,0);
			}
			ObjRender_SetPosition(obj, OptionX[num],OptionY[num], 0);
			if(PlayerType==stim)
			{
				ObjRender_SetAlpha(obj,128);
			}
			else
			{
				ObjRender_SetAlpha(obj,0);
			}
 			if(GetPlayerState==STATE_DOWN)
			{
				ObjRender_SetAlpha(obj,0);
				DownCount=50;
			}
 			if(DownCount>0)
			{
				ObjRender_SetAlpha(obj,0);
			}
			DownCount-=1;
			yield;
			
	
		}
		Obj_Delete(obj);
	}
}