// By iVAwalys.

let CSD = GetCurrentScriptDirectory;

let scroll = 0;

task BackSpell2{
	let img2 = CSD ~ "./back_img/cdbg06b.png";
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj, img2);
	ObjSprite2D_SetSourceRect(obj, 0,0,384,448);
	ObjSprite2D_SetDestRect(obj, 0,0,384,448);
	Obj_SetRenderPriorityI(obj, 21);
	ObjRender_SetScaleXYZ(obj, 1, 1, 0);
	ObjRender_SetAngleXYZ(obj, 0, 0, 0);
	ObjRender_SetPosition(obj, 0, 0, 0);
	ObjRender_SetAlpha(obj, 210);
}

function BackSpell1(locX,locY,locZ){
	let img1 = CSD ~ "./back_img/cdbg06a.png";
	let obj = ObjPrim_Create(OBJ_SPRITE_3D);
	ObjPrim_SetTexture(obj, img1);
	ObjSprite3D_SetSourceRect(obj, 0,0,256,512);
	ObjSprite3D_SetDestRect(obj, 0,0,256,512);
	Obj_SetRenderPriorityI(obj, 20);
	ObjRender_SetScaleXYZ(obj, 1, 1, 0);
	ObjRender_SetAlpha(obj, 255);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjRender_SetPosition(obj, locX,locY,locZ);
	ObjRender_SetAngleXYZ(obj, 0, 0, 0);
	ObjRender_SetColorHSV(obj, 0, 100, 200);
}

@Initialize{
	BackgroundCreate;
	BackSpell2;
	ScrollStage;
}

@MainLoop{
	scroll++;
	yield;
}

task BackgroundCreate{
	BackSpell1(16,0,0);
	BackSpell1(16,-512,0);
	BackSpell1(16,-1028,0);
}

task ScrollStage{
	SetCameraPerspectiveClip(0, 4096);
	SetCameraAzimuthAngle(90);
	SetCameraElevationAngle(0);
	SetCameraRadius(256);
	SetCameraFocusX(120);
	SetCameraFocusY(200);
	SetCameraFocusZ(0);
	
	loop{
		SetCameraFocusY(120-scroll);
		if(scroll > 512){
			scroll = 0;
		}
		yield;
	}
}