function TCharge01(x,y,s,stsx,stsy){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GCSD~"img/charge.png";
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,0,0,128,128);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetPosition(obj,x,y,0);
	ObjRender_SetAlpha(obj,0);
	ObjRender_SetScaleXYZ(obj,stsx,stsy,0);
	TAlpha;
	TShrink;
	return obj;
	task TAlpha{
		let l=10;
		let alpha=255/l;
		loop(l){
			ObjRender_SetAlpha(obj,alpha);
			alpha+=255/(l*2);
			yield;
			}
		}
	task TShrink{
		let size=stsx;
		let l=30;
		loop(l){
			ObjRender_SetScaleXYZ(obj,size,size,0);
			size-=stsx/l;
			yield;
			}
		Obj_Delete(obj);
	}
}

function TDrawBoss{
	let size=1.6;
	let signal=1;
    let objBoss=ObjEnemy_Create(OBJ_ENEMY_BOSS);
    ObjEnemy_Regist(objBoss);
    let imgRumia=GCSD~"img/rumia.png";
    ObjPrim_SetTexture(objBoss,imgRumia);
    ObjSprite2D_SetSourceRect(objBoss,2,1,63,62);
    ObjSprite2D_SetDestCenter(objBoss);
//	let circle=FDrawFamiliar(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),0,0,0,0,255,255,96,96);
//	Obj_SetRenderPriorityI(circle,20);
	let obj=FDrawMagicCircle(objBoss,0,0,4,64);
	let obj2=FDrawMagicCircle(objBoss,0,0,-4,64);
	return objBoss;
	while(!Obj_IsDeleted(objBoss)){ yield; }
		Obj_Delete(obj);
		Obj_Delete(obj2);
	}
	
function FDrawMagicCircle(BOSS,xadd,yadd,zadd,alpha){
	let xspin=0;
	let yspin=0;
	let zspin=0;
	let scale=0;
	let obj=ObjEnemy_Create(OBJ_ENEMY);
	ObjEnemy_Regist(obj);
	let imgFam=GCSD~"img/graphics2.png";
	LoadTexture(imgFam);
	ObjPrim_SetTexture(obj,imgFam);
	ObjSprite2D_SetSourceRect(obj,129,81,256,208);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetPosition(obj,0,0,0);
	ObjRender_SetAlpha(obj,alpha);
	TSpinSize;
	return obj;
	task TSpinSize{
		while(!Obj_IsDeleted(BOSS)){
			ObjRender_SetAngleXYZ(obj,xspin,yspin,zspin);
			xspin+=xadd;
			yspin+=yadd;
			zspin+=zadd;
			let result=sin(scale)/3+2.75;
			ObjRender_SetScaleXYZ(obj,result/2,result/2,0);
			scale+=3;
			ObjMove_SetPosition(obj,ObjMove_GetX(BOSS),ObjMove_GetY(BOSS));
			yield;
		}
		Obj_Delete(obj);
	}
}

function FDrawFamiliar(BOSS,x,y,z,xadd,yadd,zadd,alpha,r,g,b){
        let xspin=0;
        let yspin=0;
        let zspin=0;
		let obj=ObjEnemy_Create(OBJ_ENEMY);
        ObjEnemy_Regist(obj);
        let imgFam=GCSD~"img/etama2.png";
        ObjPrim_SetTexture(obj,imgFam);
        ObjSprite2D_SetSourceRect(obj,193,113,256,176);
        ObjSprite2D_SetDestCenter(obj);
		ObjRender_SetPosition(obj,x,y,z);
        ObjRender_SetAlpha(obj,alpha);
        ObjRender_SetColor(obj,r,g,b);
        CheckBossExists;
		TSpin;
		task TSpin{
			while(!Obj_IsDeleted(obj)){
				ObjRender_SetAngleXYZ(obj,xspin,yspin,zspin);
				xspin+=xadd;
				yspin+=yadd;
				zspin+=zadd;
				yield;
			}
		}
        return obj;
        task CheckBossExists{
                while(!Obj_IsDeleted(obj)){
                        if(ObjEnemy_GetInfo(BOSS,INFO_LIFE)<=0){
                                Obj_Delete(obj);
                        }
					yield;
                }
        }
}

task Cutin(text,textwidth){
	let alpha=0;
	let scale=4;
	let yscale=1;
	let objTxt=ObjText_Create;
	ObjText_SetText(objTxt,text);
	ObjText_SetFontSize(objTxt,textwidth);
	ObjText_SetFontColorTop(objTxt,255,255,255);
	ObjText_SetFontColorBottom(objTxt,128,128,255);
	ObjText_SetFontBorderType(objTxt,BORDER_FULL);
	ObjText_SetFontBorderColor(objTxt,0,0,200);
	ObjText_SetFontBorderWidth(objTxt,1);
	ObjText_SetHorizontalAlignment(objTxt,ALIGNMENT_RIGHT);
	ObjText_SetMaxWidth(objTxt,380);
	Obj_SetRenderPriority(objTxt,0.8);
	ObjRender_SetPosition(objTxt,GetStgFrameWidth-385,GetStgFrameHeight-150,0);
	ObjText_SetAutoTransCenter(objTxt,true);
	
	let path=GCSD~"img/rumiacutin.png";
	let cut=ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(cut,path);
    ObjSprite2D_SetSourceRect(cut,0,0,488,399);
	ObjRender_SetScaleXYZ(cut,1,1,1);
    ObjSprite2D_SetDestCenter(cut);
	ObjRender_SetPosition(cut,-(488/4),GetStgFrameHeight/2,0);
	Obj_SetRenderPriority(cut,0.50);
	TScale;
	TCut;
	task TScale{
	loop(20){
		alpha+=12.75;
		scale-=0.15;
		ObjRender_SetAlpha(objTxt,alpha);
		ObjRender_SetScaleXYZ(objTxt,scale,scale,1);
		yield;
	}
	wait(55);
	loop(20){
		yscale-=0.05;
		ObjRender_SetScaleXYZ(objTxt,1,yscale,1);
		yield;
	}
	wait(5);
	ObjRender_SetPosition(objTxt,GetStgFrameWidth-385,GetStgFrameHeight-425,0);
	loop(20){
		yscale+=0.05;
		ObjRender_SetScaleXYZ(objTxt,1,yscale,1);
		yield;
	}
	while(!Obj_IsDeleted(objBoss)){yield;}
		loop(20){
			alpha-=12.75;
			yscale+=0.05;
			ObjRender_SetAlpha(objTxt,alpha);
			ObjRender_SetScaleXYZ(objTxt,yscale,yscale,1);
			yield;
		}
		Obj_Delete(objTxt);
	}
	task TCut{
		let speed=15;
		loop(20){
			ObjRender_SetX(cut,ObjRender_GetX(cut)+speed);
			yield;
			}
		speed=1.5;
		loop(60){
			ObjRender_SetX(cut,ObjRender_GetX(cut)+speed);
			yield;
			}
		speed=15;
		while(ObjRender_GetX(cut)<GetStgFrameWidth+(488/2)){
			ObjRender_SetX(cut,ObjRender_GetX(cut)+speed);
			yield;
			}
		Obj_Delete(cut);
		}
}

task CutinLast(text,textwidth){
	let alpha=0;
	let scale=4;
	let yscale=1;
	let objTxt=ObjText_Create;
	ObjText_SetText(objTxt,text);
	ObjText_SetFontSize(objTxt,textwidth);
	ObjText_SetFontColorTop(objTxt,255,255,255);
	ObjText_SetFontColorBottom(objTxt,128,128,255);
	ObjText_SetFontBorderType(objTxt,BORDER_FULL);
	ObjText_SetFontBorderColor(objTxt,0,0,200);
	ObjText_SetFontBorderWidth(objTxt,1);
	ObjText_SetHorizontalAlignment(objTxt,ALIGNMENT_RIGHT);
	ObjText_SetMaxWidth(objTxt,380);
	Obj_SetRenderPriority(objTxt,0.8);
	ObjRender_SetPosition(objTxt,GetStgFrameWidth-385,GetStgFrameHeight-150,0);
	ObjText_SetAutoTransCenter(objTxt,true);
	
	let path=GCSD~"img/rumiacutinlast.png";
	let cut=ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(cut,path);
    ObjSprite2D_SetSourceRect(cut,0,0,488,399);
	ObjRender_SetScaleXYZ(cut,1,1,1);
    ObjSprite2D_SetDestCenter(cut);
	ObjRender_SetPosition(cut,-(488/4),GetStgFrameHeight/2,0);
	Obj_SetRenderPriority(cut,0.50);
	TScale;
	TCut;
	task TScale{
	loop(20){
		alpha+=12.75;
		scale-=0.15;
		ObjRender_SetAlpha(objTxt,alpha);
		ObjRender_SetScaleXYZ(objTxt,scale,scale,1);
		yield;
	}
	wait(55);
	loop(20){
		yscale-=0.05;
		ObjRender_SetScaleXYZ(objTxt,1,yscale,1);
		yield;
	}
	wait(5);
	ObjRender_SetPosition(objTxt,GetStgFrameWidth-385,GetStgFrameHeight-425,0);
	loop(20){
		yscale+=0.05;
		ObjRender_SetScaleXYZ(objTxt,1,yscale,1);
		yield;
	}
	while(!Obj_IsDeleted(objBoss)){yield;}
		loop(20){
			alpha-=12.75;
			yscale+=0.05;
			ObjRender_SetAlpha(objTxt,alpha);
			ObjRender_SetScaleXYZ(objTxt,yscale,yscale,1);
			yield;
		}
		Obj_Delete(objTxt);
	}
	task TCut{
		let speed=15;
		loop(20){
			ObjRender_SetX(cut,ObjRender_GetX(cut)+speed);
			yield;
			}
		speed=1.5;
		loop(60){
			ObjRender_SetX(cut,ObjRender_GetX(cut)+speed);
			yield;
			}
		speed=15;
		while(ObjRender_GetX(cut)<GetStgFrameWidth+(488/2)){
			ObjRender_SetX(cut,ObjRender_GetX(cut)+speed);
			yield;
			}
		Obj_Delete(cut);
		}
}

function SetColor(obj,c,b){
	let colour=GetRGB(c,b);
	ObjRender_SetColor(obj,colour[0],colour[1],colour[2]);
}

function GetRGB(let color,let brightness){
		alternative(color)
		case("RED") {
			alternative(brightness)
			case("NORMAL") { return [255, 51, 51]; }
			case("DARK") { return [255, 0, 0]; }
			case("BRIGHT") { return [255, 102, 102]; }
		}
		case("ORANGE") {
			alternative(brightness)
			case("NORMAL") { return [255, 153, 51]; }
			case("DARK") { return [255, 128, 0]; }
			case("BRIGHT") { return [255, 178, 102]; }
		}
		case("YELLOW") {
			alternative(brightness)
			case("NORMAL") { return [255, 255, 51]; }
			case("DARK") { return [255, 255, 0]; }
			case("BRIGHT") { return [255, 255, 102]; }
		}
		case("LIME") {
			alternative(brightness)
			case("NORMAL") { return [153, 255, 51]; }
			case("DARK") { return [128, 255, 0]; }
			case("BRIGHT") { return [178, 255, 102]; }
		}
		case("GREEN") {
			alternative(brightness)
			case("NORMAL") { return [153, 255, 153]; }
			case("DARK") { return [0, 255, 0]; }
			case("BRIGHT") { return [102, 255, 102]; }
		}
		case("MINT","TEAL") {
			alternative(brightness)
			case("NORMAL") { return [51, 255, 153]; }
			case("DARK") { return [0, 255, 128]; }
			case("BRIGHT") { return [102, 255, 178]; }
		}
		case("SKY","AQUA") {
			alternative(brightness)
			case("NORMAL") { return [51, 255, 255]; }
			case("DARK") { return [0, 255, 255]; }
			case("BRIGHT") { return [102, 255, 255]; }
		}
		case("BLUE") {
			alternative(brightness)
			case("NORMAL") { return [51, 153, 255]; }
			case("DARK") { return [0, 128, 255]; }
			case("BRIGHT") { return [102, 178, 255]; }
		}
		case("NAVY","INDIGO") {
			alternative(brightness)
			case("NORMAL") { return [51, 51, 255]; }
			case("DARK") { return [0, 0, 255]; }
			case("BRIGHT") { return [102, 102, 255]; }
		}
		case("PURPLE") {
			alternative(brightness)
			case("NORMAL") { return [153, 51, 255]; }
			case("DARK") { return [128, 0, 255]; }
			case("BRIGHT") { return [178, 102, 255]; }
		}
		case("VIOLET","MAGENTA") {
			alternative(brightness)
			case("NORMAL") { return [255, 51, 255]; }
			case("DARK") { return [255, 0, 255]; }
			case("BRIGHT") { return [255, 102, 255]; }
		}
		case("FUSCHIA","ROSE") {
			alternative(brightness)
			case("NORMAL") { return [255, 51, 153]; }
			case("DARK") { return [255, 0, 128]; }
			case("BRIGHT") { return [255, 102, 178]; }
		}
	}

task TMotionBlur(signal){
	let renderTexture = [GetReservedRenderTargetName(0), GetReservedRenderTargetName(1)];

	SetInvalidRenderPriorityA1(20, 79);

	let objCurentFrame = ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(objCurentFrame, 80);
	ObjRender_SetPermitCamera(objCurentFrame, false);

	let objOldFrame = ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(objOldFrame, 0);
	ObjRender_SetPermitCamera(objOldFrame, false);
	ObjRender_SetAlpha(objOldFrame, 224);
	Obj_SetVisible(objOldFrame, false);

	let frame = 0;
	while(signal==1){
		if(signal!=1){ break; }
		let currentFrameTexture = renderTexture[frame % 2];

		RenderToTextureA1(currentFrameTexture, 20, 79, true);

		if(frame >= 1) {
			let oldFrameTexture = renderTexture[(frame - 1) % 2];
			ObjPrim_SetTexture(objOldFrame, oldFrameTexture);
			ObjSprite2D_SetSourceRect(objOldFrame, 32, 16, 416, 464);
			ObjSprite2D_SetDestRect(objOldFrame, 32, 16, 416, 464);
			RenderToTextureB1(currentFrameTexture, objOldFrame, false);
		}

		ObjPrim_SetTexture(objCurentFrame, currentFrameTexture);
		ObjSprite2D_SetSourceRect(objCurentFrame, 32, 16, 416, 464);
		ObjSprite2D_SetDestRect(objCurentFrame, 32, 16, 416, 464);

		frame++;
		yield;
	}

	Obj_Delete(objCurentFrame);
	Obj_Delete(objOldFrame);
	ClearInvalidRenderPriority();
}