let frame=0;
let frame2=0;
let angle=0;
let isSpell=false;
let xinc = -150;

@Initialize{
SetCameraFocusX(30);
SetCameraFocusY(200);
SetCameraFocusZ(-150);
SetCameraRadius(450);
SetCameraElevationAngle(20);
SetCameraAzimuthAngle(-90);
SetFogParam(350,800,0,0,38);
Background;
}

@MainLoop{
   yield;
}

task Background{
	let texture1=GetCurrentScriptDirectory~"img/bg1.png";
	let texture2=GetCurrentScriptDirectory~"img/sky.png";
	let texture3=GetCurrentScriptDirectory~"img/lune.png";
	let sky=ObjPrim_Create(OBJ_SPRITE_2D);
	let moon=ObjPrim_Create(OBJ_SPRITE_2D);
	let bg1=ObjPrim_Create(OBJ_SPRITE_3D);
	let bg2=ObjPrim_Create(OBJ_SPRITE_3D);
	Obj_SetRenderPriority(sky,0.21);
	ObjPrim_SetTexture(sky,texture2);
	ObjSprite2D_SetSourceRect(sky,0,0,1024,1024);
	ObjSprite2D_SetDestRect(sky,0,0,1024,1024);
	ObjSprite2D_SetDestCenter(sky);
	ObjRender_SetPosition(sky,GetStgFrameWidth/2,0,0);
	ObjRender_SetAngleXYZ(sky,0,0,0);
	ObjRender_SetColor(sky,255,255,255);
	Obj_SetRenderPriority(moon,0.21);
	ObjPrim_SetTexture(moon,texture3);
	ObjSprite2D_SetSourceRect(moon,0,0,256,256);
	ObjSprite2D_SetDestRect(moon,0,0,256,256);
	ObjSprite2D_SetDestCenter(moon);
	ObjRender_SetPosition(moon,GetStgFrameWidth/2,25,0);
	ObjRender_SetAngleXYZ(moon,0,0,0);
	ObjRender_SetColor(moon,255,255,255);
	Obj_SetRenderPriority(bg1,0.21);
	ObjPrim_SetTexture(bg1,texture1);
	ObjSprite3D_SetSourceRect(bg1,0,0,1024,1024);
	ObjSprite3D_SetDestRect(bg1,0,0,1024,1024);
	ObjRender_SetAlpha(bg1, 255);
	ObjRender_SetPosition(bg1,-350,20,-500);
	ObjRender_SetAngleXYZ(bg1,90,0,0);
	Obj_SetRenderPriority(bg2,0.21);
	ObjPrim_SetTexture(bg2,texture1);
	ObjSprite3D_SetSourceRect(bg2,0,0,1024,1024);
	ObjSprite3D_SetDestRect(bg2,0,0,1024,1024);
	ObjRender_SetAlpha(bg2, 128);
	ObjRender_SetPosition(bg2,-350,120,-600);
	ObjRender_SetAngleXYZ(bg2,90,0,0);
	loop{
		frame+=4;
		frame2+=2;
		angle+=2;
		if(frame>=1024){frame=0;}
		ObjSprite3D_SetSourceRect(bg1,frame2,frame2,1024+frame2,1024+frame2);
		ObjSprite3D_SetSourceRect(bg2,-frame2/2,frame2/2,1024-frame2/2,1024+frame2/2);
		ObjRender_SetAngleXYZ(sky,0,0,5*cos(frame/32));
		yield;
	}
	yield;
}