let current = GetCurrentScriptDirectory();

@Initialize{
	SetCameraFocusX(0);
	SetCameraFocusY(0);
	SetCameraFocusZ(0);
	SetCameraRadius(900);
	SetCameraElevationAngle(-30);
	SetCameraAzimuthAngle(90);
	SetFogParam(500, 1800, 0, 0, 64);
	TMountain;
	TForest;
	TClouds;
	TSky;
	}

@MainLoop{yield;}

task TForest{
	let move = 0;

	let bg1 = current ~ "./img/stage01/st01a.png";

	let obj = ObjPrim_Create(OBJ_SPRITE_3D);
	ObjPrim_SetTexture(obj,bg1);
	Obj_SetRenderPriorityI(obj,20);

	//ObjSprite3D_SetSourceDestRect(obj,0,0,512,25600);
	ObjRender_SetAngleXYZ(obj,-220,20,20);
	//ObjRender_SetZWrite(obj, true);
	//ObjRender_SetZTest(obj, true);
	ObjRender_SetColorHSV(obj,230,210,255);

	while(!Obj_IsDeleted(obj)){
		ObjSprite3D_SetSourceDestRect(obj, -512, move*3, 512*3, 2048+move*3);
		move-=0.5; yield;}}
		
task TMountain{
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj,current ~ "./img/stage02/st02d.png");
	ObjSprite2D_SetSourceRect(obj,0,0,1024,250);
	ObjSprite2D_SetDestCenter(obj);
	Obj_SetRenderPriorityI(obj,22);
	ObjRender_SetPosition(obj,150,20,0);
	ObjRender_SetAngleXYZ(obj,0,0,-15);
	ObjRender_SetColorHSV(obj,20,210,255);
}

task TClouds{
	let move = 0;
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj,current ~ "./img/stage02/st02c.png");
	ObjSprite2D_SetSourceRect(obj,-1024*2,0,1024,256);
	ObjSprite2D_SetDestCenter(obj);
	Obj_SetRenderPriorityI(obj,23);
	ObjRender_SetPosition(obj,150,20,0);
	ObjRender_SetAngleXYZ(obj,0,0,-10);
	while(!Obj_IsDeleted(obj)){
		ObjRender_SetPosition(obj,150+350*sin(move),20,0);
		move+=0.1; yield;}
	}

task TSky{
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj,current ~ "./img/stage01/st01c.png");
	ObjSprite2D_SetSourceRect(obj,0,0,256,415);
	ObjSprite2D_SetDestCenter(obj);
	Obj_SetRenderPriorityI(obj,21);
	ObjRender_SetPosition(obj,150,20,0);
	ObjRender_SetScaleXYZ(obj,1.8,1,0);
	ObjRender_SetAngleXYZ(obj,0,0,-15);
}