#東方弾幕風[Single]
#ScriptVersion[3]
#Title["Example N"]
#System[".\Foxi's System.txt"]
#BGM[".\bgm\lab.mp3"]
#include".\system/Resources.txt"
#include".\RenderBossFunctions.txt"
#include".\OzzieEffects.txt"
#include".\ShotFunctions.txt"
#include".\MiscFunctions.txt"
#include".\shot/shot_const.txt"


let objEnemy;
let objPlayer; 
let n = 0;

@Event
{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE)
	{
		
		SetScriptResult(100);
	}
}

@Initialize
{
	PlaytestInvincibility();
	objPlayer = GetPlayerObjectID();

	objEnemy = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objEnemy);
	
	TAnimate();
	TBoss();
	let cx = GetStgFrameWidth() / 2;
	let cy = 100;
	ObjMove_SetDestAtFrame(objEnemy, cx, cy, 60);
	TMain();
}


@MainLoop{
	
	yield;
}

task TBoss(){
	while(!Obj_IsDeleted(objEnemy)){
		ObjEnemy_SetIntersectionCircleToShot(objEnemy, ObjMove_GetX(objEnemy), ObjMove_GetY(objEnemy), 10);
		ObjEnemy_SetIntersectionCircleToPlayer(objEnemy, ObjMove_GetX(objEnemy), ObjMove_GetY(objEnemy), 14);
		if(ObjEnemy_GetInfo(objEnemy, INFO_LIFE) <= 0){
			TEnd();
		}
		yield;
	}
}



task TMain
{
	wait(60);
	loop{
		movement(60);
		wait(120);
	}
}

task TEnd
{
	Set2DCameraRatioX(cos(0));
	Set2DCameraRatioY(cos(0));
	Obj_Delete(objEnemy);
	let r = 0;
	loop(60)
	{
		DeleteShotAll(TYPE_ALL,TYPE_IMMEDIATE);
		yield;
	}
	DeleteShotAll(TYPE_ALL,TYPE_IMMEDIATE);
	CloseScript(GetOwnScriptID());
}

task movement(delay){
		wait(delay);
		ObjMove_SetDestAtFrameWeight(objEnemy,GetCenterX+rand(-200, 200),GetCenterY/3,delay);
}
