
//バックグラウンド　背景、BGMなど

let const_BGX = 960*(GetClipMaxX() - GetClipMinX())/(GetClipMaxY() - GetClipMinY());
let const_BGY = 960; // GetClipMaxY() - GetClipMinY();
let m_BGcount = 100;
let m_BGSpeed = 0.05;

task once_BackGroundGraphic(){

	let obj = REMY_CreateEffectObject(img_BG01, 4, 0);
	ObjEffect_SetRenderState(obj, ALPHA);
	let rect = system_GetGraphicRect("BG_TOWN01");
	ascent(i in 0..4){
		ObjEffect_SetVertexXY(obj, i, [GetClipMinX(),GetClipMaxX()][i%2],[GetClipMinY(),GetClipMaxY()][trunc(i/2)]);
		ObjEffect_SetVertexUV(obj, i, 960 + [-const_BGX, const_BGX][i%2],480+  [-const_BGY, const_BGY][trunc(i/2)]);
		ObjEffect_SetVertexColor(obj, i, 255,230,230,230);
	}

	Obj_SetPosition(obj,0,0);
	loop{
		m_BGcount = REMY_GetNumMin(m_BGcount + m_BGSpeed, 200);
		ascent(i in 0..4){
			ObjEffect_SetVertexUV(obj, i,  [1024 - (const_BGX * m_BGcount/200) , 1024][i%2], [960-(960 * m_BGcount/200), 960][trunc(i/2)]);
		}
		loop(4){yield;}
	}

}//end task

task once_BackGroundGraphicCloud(let speed, let alpha, let black){

	let obj = REMY_CreateEffectObject(img_BG02, 8, 1);
	let rect = system_GetGraphicRect("BG_CLOUD");
	if(black){ObjEffect_SetRenderState(obj, SUBTRACT);}

	ascent(i in 0..8){
		ObjEffect_SetVertexXY(obj, i, [0, GetClipMaxX()][i%2], [0, GetCenterY()/2, GetClipMaxY()*(4/7), GetClipMaxY()][trunc(i/2)]);
		ObjEffect_SetVertexColor(obj, i, alpha - 20 * (trunc(i/2)), 200,200,200);
	}
	Obj_SetPosition(obj,0, 0);

	let bgy = 0;
	loop{
		bgy = REMY_GetNumLimited(bgy + speed, 0, 512, true );
		ascent(i in 0..8){ ObjEffect_SetVertexUV(obj, i, [0, GetClipMaxX()][i%2], bgy + (GetClipMaxY()/4 * trunc(i/2)));}
		loop(2){yield;}
	}

}//end task


function system_SetBGSpeed(let val){
	m_BGSpeed = val;
}//end function

