task Bomb{

	let objManage = GetSpellManageObject();
	
	let frame=0;
	
	Circle;
	
	SetPlayerInvincibilityFrame(395);
	
	MCircle(394);
	
	Explode2;
	
	CanShoot=false;
	
	while(!Obj_IsDeleted(objManage)){
		frame++;
		
		if(frame==350){
			Obj_Delete(objManage);
			}
		yield;
		}
		
	CanShoot=true;
	}
	
task Circle{

	let circle = ObjSpell_Create;
	ObjSpell_Regist(circle);
	ObjSpell_SetDamage(circle, 8);
	
	let mod=0;
	let X = GetPlayerX();
	let Y = GetPlayerY();
	let frame=0;
	BombBG(circle);
	while(!Obj_IsDeleted(circle)){
		ObjSpell_SetIntersectionCircle(circle, ObjRender_GetX(circle), ObjRender_GetY(circle), 400);
		ObjRender_SetPosition(circle, GetStgFrameWidth/2, GetStgFrameHeight/2, 0);
		frame++;
		
		if(frame==300){
			Obj_Delete(circle);
			}
		yield;
		}
	}
	
task BombBG(tobj){
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj, csd ~ "tai-chi.jpg");
	Obj_SetRenderPriorityI(obj,25);
	ObjSprite2D_SetSourceRect(obj,0,0,322, 320);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetPosition(obj, GetStgFrameWidth/2, GetStgFrameHeight/2, 0);
	ObjRender_SetScaleXYZ(obj, 1.8, 1.8, 0);
	ObjRender_SetColor(obj, 160, 40, 140);
	
	let obj1 = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj1, csd ~ "Hakurei_Reimu_full_1390975.png");
	Obj_SetRenderPriorityI(obj1,100);
	ObjSprite2D_SetSourceRect(obj1,0,0,598, 801);
	ObjSprite2D_SetDestCenter(obj1);
	//ObjRender_SetPosition(obj1, GetStgFrameWidth/2+20, GetStgFrameHeight/2+70, 0);
	//ObjRender_SetPosition(obj1, GetStgFrameWidth+100, GetStgFrameHeight/2+70, 0);
	ObjRender_SetPosition(obj1, -300, GetStgFrameHeight/2+70, 0);
	ObjRender_SetScaleXYZ(obj1, 0.9, 0.9, 0);
	
	let obj2 = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj2, csd ~ "Swipe.png");
	ObjRender_SetBlendType(obj2, BLEND_ADD_RGB);
	Obj_SetRenderPriorityI(obj2,99);
	ObjSprite2D_SetSourceRect(obj2,0,0,GetScreenWidth, GetScreenHeight);
	ObjSprite2D_SetDestCenter(obj2);
	ObjRender_SetPosition(obj2, GetScreenWidth/2, GetScreenHeight/2, 0);
	ObjRender_SetScaleXYZ(obj2, 0, 0, NULL);
	ObjRender_SetAlpha(obj2,255);
	
	let X = 0;
	
	StarLoop(tobj, 36);
	
	let SCALE = 0;
	let ANGLE=0;
	let frame=0;
	let ALPHA1 = 0;
	let allow=0;
	let XValue = X;
	
	while(!Obj_IsDeleted(tobj)){
		ObjRender_SetAngleXYZ(obj, 0, 0, ANGLE);
		ObjRender_SetPosition(obj1, X, GetStgFrameHeight/2+70, 0);
		
		ANGLE+=0.2;
		if(XValue<=GetStgFrameWidth+120){
			X+=28;
			XValue+=28;
			}
			
		else{
			frame++;

			}
			
		if(frame==150){
			ObjPrim_SetTexture(obj1, csd ~ "Hakurei_Reimu_full_1390957.png");
			ObjSprite2D_SetSourceRect(obj1,0,0,648, 748);
			ObjSprite2D_SetDestCenter(obj1);
			ObjRender_SetPosition(obj1, GetScreenWidth, GetStgFrameHeight/2+70, 0);
			ObjRender_SetScaleXYZ(obj2, 1, 1, NULL);
			X=GetStgFrameWidth;
			CHINK;
			}
			
		if(frame==176){
			SHRINK(obj2);
			}
	
		if(frame==220){
			ALPHASHRINK(obj1);
			}
			
		yield;
		}
	Obj_Delete(obj);
	Obj_Delete(obj1);
	
	task SHRINK(tobj){
		let SCALE=1;
		
		while(SCALE>=-0){
			ObjRender_SetScaleXYZ(tobj, SCALE, 1, NULL);
			SCALE-=0.012;
			yield;
			}
		Obj_Delete(tobj);
		}
		
	task ALPHASHRINK(tobj){
		let SCALE=0;
		let MOVE = 0;
		
		while(SCALE<=255){
			ObjRender_SetAlpha(tobj, 255-SCALE);
			ObjRender_SetPosition(tobj, ObjRender_GetX(tobj), ObjRender_GetY(tobj)+MOVE, 0);
			MOVE-=1.2;
			SCALE+=4;
			yield;
			}
		Obj_Delete(tobj);
		}
	}
	
task MCircle(COUNT){
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj, csd ~"p_ef_10.png");
	ObjSprite2D_SetSourceRect(obj,0,0,256, 256);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetPosition(obj, GetPlayerX(), GetPlayerY(), 0);
	ObjRender_SetScaleXYZ(obj, 0.8, 0.8, 0);
	ObjRender_SetBlendType(obj, BLEND_ADD_RGB);
	ObjRender_SetAlpha(obj, 130);
	Obj_SetRenderPriorityI(obj,23);
	
	let SCALE = 0.8;
	let ANGLE = 0;
	
	let allow=0;
	let frame=0;
	
	while(!Obj_IsDeleted(obj)){
		frame++;
		ObjRender_SetPosition(obj, GetPlayerX(), GetPlayerY(), 0);
		ObjRender_SetAngleXYZ(obj, 0, 0, ANGLE);
		ANGLE+=2;
		
		if(frame==COUNT-50){
			allow=1;
			}
			
		if(allow==1){
			SCALE-=0.8/50;
			ObjRender_SetScaleXYZ(obj, SCALE, SCALE, 0);
			}
			
		if(SCALE<=0){
			Obj_Delete(obj);
			}
		yield;
		}
	}
	
task Stars(tobj, count){
	
	
	let graphic=GetCurrentScriptDirectory ~ "star.png";
	let graphicx = 128;
	let graphicy = 128;
			
		let obj = ObjPrim_Create(OBJ_SPRITE_2D);
		ObjPrim_SetTexture(obj, graphic);
		Obj_SetRenderPriorityI(obj,99);
		ObjRender_SetBlendType(obj,BLEND_ADD_RGB);
		ObjRender_SetAlpha(obj,230);
		ObjSprite2D_SetSourceRect(obj,0,0,graphicx, graphicy);
		ObjSprite2D_SetDestCenter(obj);
		let ANGLE1 = rand(0, 360);
		ObjRender_SetAngleXYZ(obj,0, 0, ANGLE1);
		ObjRender_SetScaleXYZ(obj, 0.5, 0.5, NULL);
		
		let X = GetScreenWidth-GetScreenWidth;
		let Y = rand(10, GetStgFrameHeight-10);
		ObjRender_SetPosition(obj, X, Y, 0);
		let MOVE = rand(5, 15);
		
		while(X<=GetScreenWidth){
			ObjRender_SetPosition(obj, X, Y, 0);
			ObjRender_SetAngleXYZ(obj,0, 0, ANGLE1);
			ANGLE1+=5;
			X+=MOVE;
			
			yield;
			}
			
		Obj_Delete(obj);
	}
	
task Stars1(tobj, count){
	
	
	let graphic=GetCurrentScriptDirectory ~ "star.png";
	let graphicx = 128;
	let graphicy = 128;
			
		let obj = ObjPrim_Create(OBJ_SPRITE_2D);
		ObjPrim_SetTexture(obj, graphic);
		Obj_SetRenderPriorityI(obj,99);
		ObjRender_SetBlendType(obj,BLEND_ADD_RGB);
		ObjRender_SetAlpha(obj,230);
		ObjSprite2D_SetSourceRect(obj,0,0,graphicx, graphicy);
		ObjSprite2D_SetDestCenter(obj);
		let ANGLE1 = rand(0, 360);
		ObjRender_SetAngleXYZ(obj,0, 0, ANGLE1);
		ObjRender_SetScaleXYZ(obj, 0.5, 0.5, NULL);
		
		let X = GetScreenWidth;
		let Y = rand(10, GetStgFrameHeight-10);
		ObjRender_SetPosition(obj, X, Y, 0);
		let MOVE = rand(5, 15);
		
		while(X>=GetStgFrameWidth-GetStgFrameWidth){
			ObjRender_SetPosition(obj, X, Y, 0);
			ObjRender_SetAngleXYZ(obj,0, 0, ANGLE1);
			ANGLE1+=5;
			X-=MOVE;
			
			yield;
			}
			
		Obj_Delete(obj);
	}
	
task StarLoop(tobj, COUNT){
	loop(COUNT){
		Stars(tobj, 295);
		Stars1(tobj, 295);
		//Stars(tobj, 295);
		
		loop(4){
			yield;
			}
		}
	}