let current = GetCurrentScriptDirectory();
let Effect = GetCommonData("EFFECT",0);

@Initialize
{
	SetAutoDeleteObject(true);
	SetCameraFocusX(0);
	SetCameraFocusY(30);
	SetCameraFocusZ(-100);
	SetCameraRadius(300);
	SetCameraElevationAngle(5);
	SetCameraAzimuthAngle(90);

	SetFogParam(0, 1000, 32, 32, 32);
	TNormalBackground;
}

@MainLoop
{
	yield;
}

task TBlank
{
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj,GetCurrentScriptDirectory ~ "./../../system/img/WhiteSquare.png");
	ObjSprite2D_SetSourceRect(obj,0,0,1,1);
	ObjSprite2D_SetDestRect(obj,-64,-64,GetStgFrameWidth+64,GetStgFrameHeight+64);
	Obj_SetRenderPriorityI(obj,20);
	ObjRender_SetColorHSV(obj,0,0,125);
}
task TNormalBackground
{
	let alphaM = 1;
	let back = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(back,GetCurrentScriptDirectory ~ "img/Back_Normal.png");
	ObjSprite2D_SetSourceRect(back,1,1,639,479);
	Obj_SetRenderPriority(back,0.2);
	ObjSprite2D_SetDestRect(back,GetStgFrameWidth/2-320,GetStgFrameHeight/2-240,GetStgFrameWidth/2+320,GetStgFrameHeight/2+240);
	loop
		{
		if(GetCommonData("BACKGROUND_END",0) == 2)
			{
			alphaM-=1/135;
			}
		ObjRender_SetAlpha(back,255*alphaM);
		yield;
		}
	
}