	SetCameraFocusX(0);
	SetCameraFocusY(0);
	SetCameraFocusZ(0);
	SetCameraRadius(700);
    SetCameraElevationAngle(0);
	SetCameraAzimuthAngle(90);
	SetFogParam(500, 1000, 1, 1, 5);

task StageBackground{
let a = 0;
let obj = ObjPrim_Create(OBJ_SPRITE_2D);

	Obj_SetRenderPriorityI(obj,20);
	ObjPrim_SetTexture(obj,GetCurrentScriptDirectory ~ "/img/Ingame/BG1.png");
	ObjSprite2D_SetSourceRect(obj,0,0,512*2,512*2);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjRender_SetPosition(obj,GetStgFrameWidth/2, GetStgFrameHeight/2,0);
	ObjRender_SetScaleXYZ(obj, 1, 1, 1);
	
let obj2 = ObjPrim_Create(OBJ_SPRITE_2D);

	Obj_SetRenderPriorityI(obj2,20);
	ObjPrim_SetTexture(obj2,GetCurrentScriptDirectory ~ "/img/Ingame/BG2.png");
	ObjSprite2D_SetSourceRect(obj2,0,0,512*2,512*2);
	ObjSprite2D_SetDestCenter(obj2);
	ObjRender_SetBlendType(obj2,BLEND_ADD_ARGB);
	ObjRender_SetPosition(obj2,GetStgFrameWidth/2, GetStgFrameHeight/2,0);
	ObjRender_SetScaleXYZ(obj2, 1, 1, 1);
	

	loop{
	ObjSprite2D_SetSourceRect(obj,0,0+(a/15),512*2,512*2+a/15);
	ObjSprite2D_SetSourceRect(obj2,0,0+(a/5),512*2,512*2+a/5);
	a++;
	yield;
	}
}

task StageBackgroundEX{
let a = 0;
let obj = ObjPrim_Create(OBJ_SPRITE_2D);

	Obj_SetRenderPriorityI(obj,20);
	ObjPrim_SetTexture(obj,GetCurrentScriptDirectory ~ "/img/Ingame/BG1.png");
	ObjSprite2D_SetSourceRect(obj,0,0,512*2,512*2);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjRender_SetPosition(obj,GetStgFrameWidth/2, GetStgFrameHeight/2,0);
	ObjRender_SetScaleXYZ(obj, 1, 1, 1);
	
let obj2 = ObjPrim_Create(OBJ_SPRITE_2D);

	Obj_SetRenderPriorityI(obj2,20);
	ObjPrim_SetTexture(obj2,GetCurrentScriptDirectory ~ "/img/Ingame/BG2.png");
	ObjSprite2D_SetSourceRect(obj2,0,0,512*2,512*2);
	ObjSprite2D_SetDestCenter(obj2);
	ObjRender_SetBlendType(obj2,BLEND_SUBTRACT);
	ObjRender_SetPosition(obj2,GetStgFrameWidth/2, GetStgFrameHeight/2,0);
	ObjRender_SetScaleXYZ(obj2, 1, 1, 1);
	

	loop{
	ObjSprite2D_SetSourceRect(obj,0,0+(a/15),512*2,512*2+a/15);
	ObjSprite2D_SetSourceRect(obj2,0,0+(a/5),512*2,512*2+a/5);
	a++;
	yield;
	}
}



task ShouBackground{
ChainSet;
Card([198, 132, 39]);
Background4;
Background2;Background2;Background2;Background2;Background2;Background2;Background2;
Background1;
Background3;
Fade;
}

task Background1{
	let count = 0;
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	
	Obj_SetRenderPriorityI(obj,21);
	ObjPrim_SetTexture(obj,GetCurrentScriptDirectory ~ "/img/Ingame/Shou1.png");
	ObjSprite2D_SetSourceRect(obj,0,0,787,787);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjRender_SetPosition(obj,GetStgFrameWidth/2, GetStgFrameHeight/2,0);
	ObjRender_SetScaleXYZ(obj, 0.8, 0.8, 1);
	loop{
	ObjRender_SetAlpha(obj, 200+55*cos(count/3));
	count++;
	yield;
	}
	Obj_Delete(obj);
}

task Background2{
	let count = 0;
	let alpha = 0;
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	
	Obj_SetRenderPriorityI(obj,21);
	ObjPrim_SetTexture(obj,GetCurrentScriptDirectory ~ "/img/Ingame/Shou2.png");
	ObjSprite2D_SetSourceRect(obj,0,0,512*2,512*2);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
	ObjRender_SetPosition(obj,GetStgFrameWidth/2, GetStgFrameHeight/2,0);
	ObjRender_SetScaleXYZ(obj, 1, 1, 1);
	loop{
	ObjSprite2D_SetSourceRect(obj,0,0-count,512*2,512*2-count);
	ObjRender_SetColor(obj, 81, 54, 16);
	ObjRender_SetAlpha(obj, alpha);
	if(alpha<255){alpha+=5;}
	count+=2;
	yield;
	}
	Obj_Delete(obj);
}

task Background3{
	let count = 0;
	let alpha = 0;
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	
	Obj_SetRenderPriorityI(obj,21);
	ObjPrim_SetTexture(obj,GetCurrentScriptDirectory ~ "/img/Ingame/Shou3.png");
	ObjSprite2D_SetSourceRect(obj,0,0,512*2,512*2);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjRender_SetPosition(obj,GetStgFrameWidth/2, GetStgFrameHeight/2,5);
	ObjRender_SetScaleXYZ(obj, 1, 1, 1);
	loop{
	ObjSprite2D_SetSourceRect(obj,0+count/3,-count/3,256*6+count/3,-count/3+256*6);
	ObjRender_SetAlpha(obj, alpha);
	if(alpha<255){alpha+=5;}
	count++;
	yield;
	}
	Obj_Delete(obj);
}

task Background4{
	let count = 0;
	let alpha = 0;
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	
	Obj_SetRenderPriorityI(obj,21);
	ObjPrim_SetTexture(obj,GetCurrentScriptDirectory ~ "/img/Ingame/Shou4.png");
	ObjSprite2D_SetSourceRect(obj,0,0,512,512);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjRender_SetPosition(obj,GetStgFrameWidth/2, GetStgFrameHeight/2,5);
	ObjRender_SetScaleXYZ(obj, 1.3, 1.2, 1);
	loop{
	ObjRender_SetAlpha(obj, alpha);
	if(alpha<255){alpha+=5;}
	count-=64;
	yield;
	}
	Obj_Delete(obj);
}

task Fade{
	let alpha = 255;
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(obj,25);
	ObjPrim_SetTexture(obj,GetCurrentScriptDirectory~"./img/Ingame/black.png");
	ObjSprite2D_SetSourceRect(obj,0,0,256,256);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetScaleXYZ(obj,5,5,5);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjRender_SetAlpha(obj, 255);
	wait(60);
	loop(60){
		alpha-=255/60;
		ObjRender_SetAlpha(obj,alpha);
	yield;}
	Obj_Delete(obj);
}

task ChainSet{
	loop(6){
	Chain(GetStgFrameWidth/2, GetStgFrameHeight/2, rand(0, 0.4),  rand(0, 0.4),  rand(0, 360));
	}
}

task Chain(x, y, xvel, yvel, ang){
	let alpha = 255;
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriority(obj,0.28);
	ObjPrim_SetTexture(obj,GetCurrentScriptDirectory~"./img/Card/chain.png");
	ObjSprite2D_SetSourceRect(obj,0,0,20,2200);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetScaleXYZ(obj,1,1,1);
	ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
	ObjRender_SetAlpha(obj, 255);
	ObjRender_SetAngleZ(obj, ang);
	ObjRender_SetPosition(obj, x,y,0);
	let count = 0;
	loop(150){
	ObjSprite2D_SetSourceRect(obj,0,count,20,count-2200);
	ObjRender_SetPosition(obj, x+(count/6*xvel),y+(count/6*yvel),0);
	count+=6;
	yield;}
	
	loop(60){
	ObjSprite2D_SetSourceRect(obj,0,count,20,count-2200);
	ObjRender_SetPosition(obj, x+(count/6*xvel),y+(count/6*yvel),0);
	count+=6;
	
	alpha-=255/60;
	ObjRender_SetAlpha(obj,alpha);
	yield;}
	Obj_Delete(obj);
}

task Card(color){
let a =ObjPrim_Create(OBJ_SPRITE_2D);
let b =ObjPrim_Create(OBJ_SPRITE_2D);
let c =ObjPrim_Create(OBJ_SPRITE_2D);
let d =ObjPrim_Create(OBJ_SPRITE_2D);
let e =ObjPrim_Create(OBJ_SPRITE_2D);
let f =ObjPrim_Create(OBJ_SPRITE_2D);
let g =ObjPrim_Create(OBJ_SPRITE_2D);
let h =ObjPrim_Create(OBJ_SPRITE_2D);
let SplitCard = [a, b, c, d, e, f, g, h];

	ascent(i in 0..length(SplitCard)){
	ObjPrim_SetTexture(SplitCard[i], CardAr[i]);
	ObjRender_SetBlendType(SplitCard[i], BLEND_ALPHA);
	Obj_SetRenderPriority(SplitCard[i], 0.28);
	ObjSprite2D_SetSourceRect(SplitCard[i], 0, 0, 190, 500);
	ObjSprite2D_SetDestCenter(SplitCard[i]);
	ObjRender_SetColor(SplitCard[i], color[0], color[1], color[2]);
	ObjRender_SetAlpha(SplitCard[i], 0);
	ObjRender_SetScaleXYZ(SplitCard[i], 4, 4, 1);
	ObjRender_SetPosition(SplitCard[i], GetStgFrameWidth/2, GetStgFrameHeight/2, 0);
	ScaleDown(SplitCard[i]);
	}
	wait(30);
	let angle = 45;
	CornerMove(SplitCard[0],0, 180, -1);
	CornerMove(SplitCard[1],90, 90, 1);
	CornerMove(SplitCard[2],180, 90, 1);
	CornerMove(SplitCard[3],270, 180, -1);
	
	BorderSpin(SplitCard[4]);
	
	let Scaling = 0;
	
	ScaleUpABit(SplitCard[5], 1);
	ScaleUpABit(SplitCard[6], 200);
	
	ScalaleUpdown(SplitCard[5], 1.5);
	
	Spiiiin(SplitCard[5], 1);
	Spiiiin(SplitCard[6], -1);
	Spiiiin(SplitCard[7], 1);
	
	wait(60);
	
	AlphaDownAndDelete(SplitCard[5],100);
	AlphaDownAndDelete(SplitCard[6],100);
	wait(30);
	AlphaDownAndDelete(SplitCard[4],100);
	AlphaDownAndDelete(SplitCard[7],100);
	AlphaDownAndDelete(SplitCard[0],100);
	AlphaDownAndDelete(SplitCard[1],100);
	AlphaDownAndDelete(SplitCard[2],100);
	AlphaDownAndDelete(SplitCard[3],100);
	
	task AlphaDownAndDelete(obj,mult){
	let alpha = 255;
	loop(mult){
	alpha-=255/mult;
	ObjRender_SetAlpha(obj,alpha);
	yield;}
	Obj_Delete(obj);
	}
	
	task ScalaleUpdown(obj, mult){
	wait(35);
	while(!Obj_IsDeleted(obj)){
	Scaling+=0.002*mult;
	ObjRender_SetScaleXYZ(obj, 1+Scaling, 1+Scaling, 1);
	yield;}
	}
	
	task Spiiiin(obj, mult){
	wait(30);
		while(!Obj_IsDeleted(obj)){
		let angle = ObjRender_GetAngleZ(obj);
		ObjRender_SetAngleZ(obj, angle+(6*mult));
		yield;
		}
	}
	
	task ScaleUpABit(obj, mult){
	loop(5){
	Scaling+=0.0005*(mult*0.7);
	ObjRender_SetScaleXYZ(obj, 1+Scaling, 1+Scaling, 1);
	yield;}
	}
	
	
	task BorderSpin(obj){
	let scale = 0;
		while(!Obj_IsDeleted(obj)){
		let angle = ObjRender_GetAngleZ(obj);
		ObjRender_SetAngleZ(obj, angle+6);
		scale+=0.002;
		ObjRender_SetScaleXYZ(obj, 0.7+scale, 0.7+scale, 1);
		yield;
		}
	}
	
	task ScaleDown(obj){
	let alpha = 0;
	let scale = 0;
	loop(15){
	alpha+=4.1*4;
	ObjRender_SetAlpha(obj,alpha);
	scale+=0.055*4;
	ObjRender_SetScaleXYZ(obj, 4-scale, 4-scale, 1);
	yield;}
	}	
		task CornerMove(obj, i,mult, multi){
		let radius = 0;
		let X = GetStgFrameWidth/2;
		let Y = GetStgFrameHeight/2;
		loop(10){
		ObjRender_SetPosition(obj, X+radius*cos(angle+(i*360/4)+mult), Y+radius*sin(angle+(i*360/4)+mult), 0);
		radius+=6;
		yield;
		}
		wait(40);
		loop(160){
		ObjRender_SetPosition(obj, X+radius*cos(angle+(i*360/4)+mult), Y+radius*sin(angle+(i*360/4)+mult), 0);
		ObjRender_SetAngleZ(obj, ObjRender_GetAngleZ(obj)+(1*multi));
		radius-=0.5;
		yield;
		}
		}
}
let C1 =  GetCurrentScriptDirectory~"./img/Card/card1.png";
let C2 =  GetCurrentScriptDirectory~"./img/Card/card2.png";
let C3 =  GetCurrentScriptDirectory~"./img/Card/card3.png";
let C4 =  GetCurrentScriptDirectory~"./img/Card/card4.png";
let C5 =  GetCurrentScriptDirectory~"./img/Card/card5.png";
let C6 =  GetCurrentScriptDirectory~"./img/Card/card6.png";
let C7 =  GetCurrentScriptDirectory~"./img/Card/card7.png";
let C8 =  GetCurrentScriptDirectory~"./img/Card/card8.png";
let CardAr = [C1, C2, C3, C4, C5, C6, C7, C8];