//Ž©‹@•\Ž¦
task TImage
{
	
	let bit = 1;
	
	Obj_SetRenderPriorityI(objPlayer,44);
	//ObjRender_SetBlendType(objPlayer, BLEND_ADD_RGB);
	let FrameCount=0;
	let RectX=[];
	let RectY=[];
	let InvincibleFrame=0;
	loop
	{
		let path = IMG_PLAYER;
		let XX = GetTextureWidth(IMG_PLAYER)/8;
		let XX2 = GetTextureWidth(IMG_PLAYER)/8;
		let YY = GetTextureHeight(IMG_PLAYER)/3;
		let YY2 = GetTextureHeight(IMG_PLAYER)/3;
		ObjPrim_SetTexture(objPlayer, path);
		if(GetVirtualKeyState(VK_RIGHT) == KEY_PUSH || SpellMove==1)
		{
			RectY=[YY*2,YY*3];
			FrameCount=5;
		}
		else if(GetVirtualKeyState(VK_RIGHT) == KEY_HOLD || SpellMove>1)
		{
			RectY=[YY*2,YY*3];
			
			if(FrameCount==0)
			{
					FrameCount=20;
			}
			
			else if(FrameCount==6)
			{
				FrameCount=10;
			}
			else if(FrameCount==11)
			{
				FrameCount=15;
			}
			else if(FrameCount==16)
			{
				FrameCount=20;
			}
		}
		else if(GetVirtualKeyState(VK_LEFT) == KEY_PUSH || SpellMove==-1)
		{
			RectY=[YY*1,YY*2];
			FrameCount=5;
		}
		else if(GetVirtualKeyState(VK_LEFT) == KEY_HOLD || SpellMove<-1)
		{
			RectY=[YY*1,YY*2];
			if(FrameCount==0){FrameCount=20;}
			else if(FrameCount==6)
			{
				FrameCount=10;
			}
			else if(FrameCount==11)
			{
				FrameCount=15;
			}
			else if(FrameCount==16)
			{
				FrameCount=20;
			}
		}
		else
		{
			RectY=[YY*0,YY];
		}

		if(RebirthFlag)
		{
			RectY=[YY*0,YY];
		}

		ObjSprite2D_SetDestCenter(objPlayer);
 		if(GetPlayerState==STATE_NORMAL)
		{
			ObjRender_SetAlpha(objPlayer,255);
			ObjRender_SetColor(objPlayer,255,255,255);
		}

		if(GetPlayerInvincibilityFrame>0 || InvincibleCount>0)
		{
			if(InvincibleFrame%3==2)
			{
				ObjRender_SetColor(objPlayer,255,32,32);
			}
		}
		if( GetPlayerState==STATE_HIT )
		{
			if(InvincibleFrame%3==2)
			{
				ObjRender_SetColor(objPlayer,0,0,0);
			}
		}
		RectX=[0+XX*floor(FrameCount/5),XX+XX*floor(FrameCount/5)];
		ObjSprite2D_SetSourceRect(objPlayer, RectX[0], RectY[0], RectX[1], RectY[1]);
		if(bit==1)
		{
			FrameCount+=0.5;
		}
		bit*=-1;
		if(FrameCount>=5*8){FrameCount=0;}
		InvincibleFrame+=1;
		yield;
	}
}