let CSD = GetCurrentScriptDirectory;
let objScene = GetEnemyBossSceneObjectID;

let OnSpell = false;

@Initialize{
	SetCameraFocusX(0);
	SetCameraFocusY(0);
	SetCameraFocusZ(0);
	SetCameraRadius(800);
    SetCameraElevationAngle(-15);
	SetCameraAzimuthAngle(90);

	bgcontrol;
}

@MainLoop{
     

OnSpell = (GetEnemyBossSceneObjectID != ID_INVALID && ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID, INFO_IS_SPELL)); 

	yield;
	}


task bgcontrol{
Background;

}

function SpriteCreate{
let obj = ObjPrim_Create(OBJ_SPRITE_3D);
ObjPrim_SetTexture(obj,CSD~"./img/BG/stgbg.png");
Obj_SetRenderPriorityI(obj,20);
ObjRender_SetAngleX(obj,-40);
ObjSprite3D_SetSourceDestRect(obj,0,0,128,128);
ObjRender_SetScaleXYZ(obj,1.5,1.5,1.5);
ObjRender_SetBlendType(obj,BLEND_ALPHA);
return obj;

let obj2 = ObjPrim_Create(OBJ_SPRITE_3D);
ObjPrim_SetTexture(obj2,CSD~"./img/BG/stgbg.png");
Obj_SetRenderPriorityI(obj2,21);
ObjRender_SetAngleX(obj2,-40);
ObjSprite3D_SetSourceDestRect(obj2,0,0,128,128);
ObjRender_SetScaleXYZ(obj2,1.5,1.5,1.5);
ObjRender_SetBlendType(obj2,BLEND_ALPHA);
return obj2;
}

task Background{

	let obj1 = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjRender_SetBlendType(obj1, BLEND_ALPHA);
	Obj_SetRenderPriorityI(obj1, 21);
	ObjPrim_SetTexture(obj1, GetCurrentScriptDirectory~"./img/BG/stgbg1.png");
	ObjRender_SetScaleXYZ(obj1, 1.4, 1.4, 1);
	ObjSprite2D_SetSourceRect(obj1, 0, 0, 556, 150);
	ObjSprite2D_SetDestCenter(obj1);
	ObjRender_SetPosition(obj1, GetStgFrameWidth/2, 105, 0);

let obj = [SpriteCreate];
ObjRender_SetAlpha(obj[0],255);
let obj2 = [SpriteCreate];
ObjRender_SetAlpha(obj2[0],100);
    let movel=40;
	let movel2=40;
	let movel3=0;
	let movel4=0;
	loop
	{
    movel+=0.25;
    movel2+=1.5;
	movel3+=0.75;
	movel4+=0.5;
    ObjSprite3D_SetSourceDestRect(obj[0],0,0+movel2,(256*6)+movel,(256*6)+movel2);
    ObjSprite3D_SetSourceDestRect(obj2[0],0,0+movel3,(256*6)+movel4,(256*6)+movel2);
    
	yield;}
}


function wait(w) { loop(w) { yield; } } 