script_shot E_Item
{//エクステンドアイテム
	let cx=GetCenterX();//STGシーンの中心x座標を取得
	let cy=GetCenterY();//STGシーンの中心y座標を取得
	let imgItem=GetCurrentScriptDirectory~"img\effect_tiny.png";
	let imgScore =GetCurrentScriptDirectory~"img\imgScore.png";
	let power33	=GetCurrentScriptDirectory~"SE\power33.wav";
	let EndSwich = false;
	let speed=3;
	@Initialize
	{
		SetAngle(-90);
		SetBombResist;
                Tmain;
	}
	
	@MainLoop
	{
		yield;
	}

        task Tmain{
		Move;
		loop{
			if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD){
				if(GetX<=GetPlayerX+48&&
				   GetX>=GetPlayerX-48&&
			 	   GetY<=GetPlayerY+48&&
			 	   GetY>=GetPlayerY-48){
			 	   GetMove(4);
				   break;
				}
			}
			if(GetX<=GetPlayerX+28&&
			   GetX>=GetPlayerX-28&&
		 	   GetY<=GetPlayerY+28&&
			   GetY>=GetPlayerY-28){
				GetMove(4);
				break;
			}
			if(GetPlayerY<=150){//上部回収
				GetMove(12);
				break;
			}
			yield;
		}
        }
	task Move{//自由落下
		loop{
             		if(GetY>GetClipMaxY+32){End;}
			if(speed>=-2){speed-=0.04;}
			SetSpeed(speed);
			yield;
		}
	}

	task GetMove(Mspeed){//低速時のアイテム吸収モーション
		speed=-Mspeed;//同時に自由落下停止
		loop{
			SetAngle(GetAngleToPlayer+180);
			if(GetX<=GetPlayerX+18&&
			   GetX>=GetPlayerX-18&&
		 	   GetY<=GetPlayerY+18&&
			   GetY>=GetPlayerY-18){
				EndSwich = true;	//描画停止
				ExtendTask;
				break;
			}
			yield;
		}
	}

	task ExtendTask{
		let Life =GetCommonData("PlayerLife");
		SetCommonData("PlayerLife",Life+1);	//"PlayerLife"増加
		PlaySE(power33);			//効果音
		let Y=0;
		let obj=Obj_Create(OBJ_EFFECT);
		Obj_SetAutoDelete(obj,false);
		ObjEffect_SetTexture(obj,imgScore);
		ObjEffect_SetPrimitiveType(obj,PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_CreateVertex(obj,4);
		ObjEffect_SetVertexColor(obj,0,255,255,128,255);
		ObjEffect_SetVertexColor(obj,1,255,255,128,255);
		ObjEffect_SetVertexColor(obj,2,255,255,64,255);
		ObjEffect_SetVertexColor(obj,3,255,255,64,255);
		ObjEffect_SetVertexUV(obj,0,176,32);
		ObjEffect_SetVertexUV(obj,1,256,32);
		ObjEffect_SetVertexUV(obj,2,176,64);
		ObjEffect_SetVertexUV(obj,3,256,64);
		ObjEffect_SetLayer(obj,8);	
		Obj_SetPosition(obj,cx,cy-200);
		loop(10){
			Y+=16/10;
			ObjEffect_SetVertexXY(obj,0,-40,-Y);
			ObjEffect_SetVertexXY(obj,1, 40,-Y);
			ObjEffect_SetVertexXY(obj,2,-40, Y);
			ObjEffect_SetVertexXY(obj,3, 40, Y);
			yield;
		}
		loop(120){yield;}
		loop(10){
			Y-=16/10;
			ObjEffect_SetVertexXY(obj,0,-40,-Y);
			ObjEffect_SetVertexXY(obj,1, 40,-Y);
			ObjEffect_SetVertexXY(obj,2,-40, Y);
			ObjEffect_SetVertexXY(obj,3, 40, Y);
			yield;
		}
		Obj_Delete(obj);
		End;
	}

	@Finalize
	{

	}
	
	@DrawLoop
	{//描画
		if(EndSwich==true){break;}
		SetTexture(imgItem);
		SetGraphicRect(32,192,48,208);
		DrawGraphic(GetX(),GetY());
	}

}