//Code made by Darkness1	

    //||---------------------------------------------------------------------------------------------------------||
    //||--||Task for drawing the sunflower field background.||---------------------------------------------------||
     let CSD = GetCurrentScriptDirectory;
let cx = GetStgFrameWidth/2;
let cy = GetStgFrameHeight/2;

    task SunflowerField(Size){
 
    let SFobj = ObjPrim_Create(OBJ_SPRITE_3D);
    let SFimg = GetCurrentScriptDirectory ~ "gbg1.png";
     let move = 0;
    LoadTexture(SFimg);
    ObjPrim_SetTexture(SFobj,SFimg);
    ObjSprite3D_SetSourceRect(SFobj,0,0,256*Size,256*Size);
    ObjSprite3D_SetDestRect(SFobj,-128*Size,-128*Size,128*Size,128*Size);
  
    ObjRender_SetAngleXYZ(SFobj,-100,75,0);
     
    SetCameraRadius(700);
     
    //SetFogEnable(true);
    //SetFogParam(1100,1500,125,0,0);
     
    Obj_SetRenderPriorityI(SFobj,20);
     
    while(!Obj_IsDeleted(SFobj)){
  ObjSprite3D_SetSourceDestRect(SFobj,0*Size,0*Size,256*Size,256*Size+move);
move += 15.231;
    yield;
    }}
     
     
    //||---------------------------------------------------------------------------------------------------------||
    //||--||Spellcard background - Overlay.||--------------------------------------------------------------------||
     
    task SpellBGoverlay(){
    let sblayobj = ObjPrim_Create(OBJ_SPRITE_2D);
    let sblayimg = CSD ~ "BG/bgoverlay.png";
     
    let sbalpha = 0;
     
    LoadTexture(sblayimg);
    ObjPrim_SetTexture(sblayobj,sblayimg);
    ObjSprite2D_SetSourceRect(sblayobj,0,0,256,256);
    ObjSprite2D_SetDestCenter(sblayobj);
    ObjSprite2D_SetDestRect(sblayobj,-128,-128,128,128);
    Obj_SetRenderPriorityI(sblayobj,20);
    ObjRender_SetPosition(sblayobj,cx,cy,0);
    ObjRender_SetScaleXYZ(sblayobj,3,3,3);
     
     
    while(!Obj_IsDeleted(sblayobj)){
     
    ObjRender_SetAlpha(sblayobj,sbalpha);
     
    if(sbalpha<255){sbalpha+=2;}
    if(sbalpha>255){sbalpha=255;}
     
    yield;
    }}
     
    //||---------------------------------------------------------------------------------------------------------||
    //||--||Spellcard background - Back.||-----------------------------------------------------------------------||
     
    task SpellBG1(){
    let sbobj1 = ObjPrim_Create(OBJ_SPRITE_2D);
    let sbimg = CSD ~ "BG/DRI_b2s1.png";
     
    let sbalpha = 0;
    let sbspin = 0;
     
    LoadTexture(sbimg);
    ObjPrim_SetTexture(sbobj1,sbimg);
    ObjSprite2D_SetDestCenter(sbobj1);
    ObjSprite2D_SetSourceRect(sbobj1,0,0,512,512);
    ObjSprite2D_SetDestCenter(sbobj1);
    //ObjSprite2D_SetDestRect(sbobj1,-256,-256,256,256);
    Obj_SetRenderPriorityI(sbobj1,20);
    ObjRender_SetPosition(sbobj1,cx,cy,0);
    ObjRender_SetScaleXYZ(sbobj1,1,1,1);
     
    while(!Obj_IsDeleted(sbobj1)){
     
    ObjRender_SetAlpha(sbobj1,sbalpha);
     
    ObjRender_SetAngleXYZ(sbobj1,0,0,sbspin);
     
    //sbspin-=0.5;
     
    if(sbalpha<200){sbalpha+=2;}
    if(sbalpha>200){sbalpha=200;}
     
    yield;
    }}
     
    //||---------------------------------------------------------------------------------------------------------||
    //||--||Spellcard background - Front.||----------------------------------------------------------------------||
     
    task SpellBG2(){
    let sbobj2 = ObjPrim_Create(OBJ_SPRITE_2D);
    let sbimg = CSD ~ "BG/DRI_b2s2.png";
     
    let sbalpha = 0;
    let sbscroll = 0;
     
    LoadTexture(sbimg);
    ObjPrim_SetTexture(sbobj2,sbimg);
    
 ObjSprite2D_SetSourceRect(sbobj2,0,0,256*2,256*2);
ObjSprite2D_SetDestCenter(sbobj2);
    //ObjSprite2D_SetDestRect(sbobj2,-256,-256-100,256,256+100);
    Obj_SetRenderPriorityI(sbobj2,20);
    ObjRender_SetPosition(sbobj2,cx,cy,0);
    ObjRender_SetScaleXYZ(sbobj2,1,1,1);
     
     
    while(!Obj_IsDeleted(sbobj2)){
     
    ObjRender_SetAlpha(sbobj2,sbalpha);
     
    //ObjSprite2D_SetSourceRect(sbobj2,0,0-100+sbscroll,512,512+100+sbscroll);
     
    sbscroll+=0;
     
    if(sbalpha<100){sbalpha+=2;}
    if(sbalpha>100){sbalpha=100;}
     
    yield;
    }}


	   task SpellBG3(){
    let sbobj2 = ObjPrim_Create(OBJ_SPRITE_2D);
    let sbimg = CSD ~ "BG/DRI_b3s1.png";
     
    let sbalpha = 0;
    let sbscroll = 0;
     
    LoadTexture(sbimg);
    ObjPrim_SetTexture(sbobj2,sbimg);
    
 ObjSprite2D_SetSourceRect(sbobj2,0,0,256*2,256*2);
ObjSprite2D_SetDestCenter(sbobj2);
    //ObjSprite2D_SetDestRect(sbobj2,-256,-256-100,256,256+100);
    Obj_SetRenderPriorityI(sbobj2,20);
    ObjRender_SetPosition(sbobj2,cx,cy,0);
    ObjRender_SetScaleXYZ(sbobj2,1,1,1);
     
     
    while(!Obj_IsDeleted(sbobj2)){
     
    ObjRender_SetAlpha(sbobj2,sbalpha);
     
    //ObjSprite2D_SetSourceRect(sbobj2,0,0-100+sbscroll,512,512+100+sbscroll);
     
    sbscroll+=0;
     
    if(sbalpha<200){sbalpha+=2;}
    if(sbalpha>200){sbalpha=200;}
     
    yield;
    }}

