let img_bg1 = GetCurrentScriptDirectory() ~ "img\bg_mystia1.png";
let img_bg2 = GetCurrentScriptDirectory() ~ "img\bg_mystia2.png";
let bg_y = 0;
let bg_alpha = 0.0;

@BackGround()
{
	SetTexture(img_bg1);
	SetGraphicRect(0, 0, 384, 448);
	SetAlpha(255 * bg_alpha);
	DrawGraphic(GetCenterX(), GetCenterY());

	SetTexture(img_bg2);
	SetAlpha(255 * bg_alpha);
	SetGraphicRect(0, 448 - bg_y, 384, 448);
	DrawGraphic(GetCenterX(), GetClipMinY() + bg_y / 2);
	SetGraphicRect(0, 0, 384, 448 - bg_y);
	DrawGraphic(GetCenterX(), GetCenterY() + bg_y / 2);
}

task InitializeBG()
{
	LoadGraphic(img_bg1);
	LoadGraphic(img_bg2);

	loop{
		bg_y += 2;
		if( bg_y >= 448 ){
			bg_y -= 448;
		}
		bg_alpha = min(bg_alpha + 0.01, 1.0);
		yield;
	}
}

function ClearBG()
{
	DeleteGraphic(img_bg1);
	DeleteGraphic(img_bg2);
}
