let stgx=GetStgFrameWidth()/2;
let stgy=GetStgFrameHeight()/2;
let GCSD = GetCurrentScriptDirectory();

@Initialize
{
SetDefaultBonusItemEnable(false);
LoadItemData(GCSD~"Item_Data.txt");
}

@MainLoop
{
	//CollectItemsInCircle(ObjMove_GetX(GetPlayerObjectID),ObjMove_GetY(GetPlayerObjectID),70);
	//if(ObjMove_GetY(GetPlayerObjectID)<133){CollectAllItems;}
	yield;
}

@Event
{
	alternative(GetEventType())
	case(EV_END_BOSS_STEP){
		SetAutoDeleteObject(true);
		DeleteWave(GetCommonData("ItemEnd",5));
	}
//	case(EV_FAM_DIE){
//		let enemy = GetAllEnemyID;
//		}
	case(EV_GET_ITEM){
	//PlaySound("item",85,0);
		if(GetEventArgument(0)==ITEM_SPELL){
		//PlaySound("item",90,0);
		SetPlayerSpell(GetPlayerSpell+1);
		}
		if(GetEventArgument(0)==ITEM_1UP){
		//PlaySound("extend",90,0);
		SetPlayerLife(GetPlayerLife+1);
		}
		if(GetEventArgument(0)==1){
		AddScore(75);
		}
	}
	case(EV_DELETE_SHOT_TO_ITEM){
		let obj = GetEventArgument(0);
		let point = GetEventArgument(1);
		let graphic = ObjShot_GetImageID(obj);
		let px = GetCommonData("BossX",0);
		let py = GetCommonData("BossY",0);
		CreateDeleteItem(point[0],point[1]);
		CreateDeleteItem(point[0],point[1]);
		CreateDeleteItem(point[0],point[1]);
		CreateDeleteItem(point[0],point[1]);
	}
}

task CreateDeleteItem(x,y) {
	let obj = CreateItemU1(1,x,y,100);
	let time = 0;
	ObjItem_SetRenderScoreEnable(obj,false);
	ObjMove_SetAngle(obj, 270+rand(-10,10));
	let speed = rand(1,1.5);
	ObjRender_SetScaleXYZ(obj,1,1,1);
	time = 30;
		descent(i in 0..time){
		ObjMove_SetSpeed(obj,speed*i/time);
		yield;
		}
	ObjItem_SetDefinedMovePatternA1(obj,ITEM_MOVE_TOPLAYER);
}

task DeleteWave(type){
		let wave = 0;
		loop(60-type*58){
			DeleteShotInCircle(TYPE_ALL,TYPE_ITEM,GetCommonData("BossX",0),GetCommonData("BossY",0),wave);
			if(type==0){wave += 20;}
			if(type==1){wave+=500;}
			yield;
		}
}