
task Mort {
	while(GetPlayerLife()>=0) {
	yield;
	}
	RunPauseScene();
}

function RunPauseScene()
{
	let dir = GetCurrentScriptDirectory();

	CloseStgScene();
}

function RenderSceneToTransitionTexture()
{
	//現在のシーン内容を画面遷移用テクスチャに描画
	let textureName = GetTransitionRenderTargetName();
	RenderToTextureA1(textureName, 0, 100, true);
}

task BottomEnemyMarker(aaa){
  let imgnumber = GetCurrentScriptDirectory~"img/enemymarker.png";
  let objMarker = ObjPrim_Create(OBJ_SPRITE_2D);
  ObjRender_SetPosition(objMarker, GetStgFrameWidth/2, GetStgFrameHeight+32, 1); 
  ObjPrim_SetPrimitiveType(objMarker, PRIMITIVE_TRIANGLESTRIP);
  ObjRender_SetBlendType(objMarker, BLEND_ALPHA);
  Obj_SetRenderPriority(objMarker, 0.85);
  ObjPrim_SetTexture(objMarker, imgnumber);
  ObjRender_SetAlpha(objMarker, 255);
  ObjSprite2D_SetSourceRect(objMarker, 0, 0, 48, 16);
  ObjSprite2D_SetDestRect(objMarker, -25, -8, 25, 8);

 
  while(!Obj_IsDeleted(GetEnemyBossSceneObjectID)){
	
    ObjRender_SetPosition(objMarker, ObjMove_GetX(aaa)+30, GetStgFrameHeight+24, 1);
	
    yield;
  }
  Obj_Delete(objMarker);
}

function renderSpellCard666 {
	// background
	let CSD = GetCurrentScriptDirectory;
	let texSpellCard = CSD ~ "img/SpellCardBoss666.png";
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(obj,21); 
	ObjPrim_SetTexture(obj,texSpellCard); 
	ObjSprite2D_SetSourceRect(obj,0,0,540,870);
	ObjSprite2D_SetDestRect(obj,0,0,GetStgFrameWidth,560);
	scroll666(obj);
	couleur666(obj);
	Apparition666;
}

task Apparition666 {
	let CSD = GetCurrentScriptDirectory;
	let texSpellCard = CSD ~ "img/FeeDesFlammesOmbre.png";
	let portrait = ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(portrait,21);
	ObjPrim_SetTexture(portrait, texSpellCard);
	ObjRender_SetBlendType(portrait, BLEND_ALPHA);
	ObjSprite2D_SetSourceRect(portrait, 0, 0, 720, 720);
	ObjRender_SetColor(portrait,222,222,222);
	let left = -500;
	let right = 0;
	let top = 200;
	let bot = 700;
	ObjSprite2D_SetDestRect(portrait, left, top, right, bot);
	loop(50) {
		ObjSprite2D_SetDestRect(portrait, left, top, right, bot);
		left += 6;
		right += 6;
		top -=3;
		bot -=3;
		yield;
	}
	loop(100) {
		ObjSprite2D_SetDestRect(portrait, left, top, right, bot);
		left += 2.5;
		right += 2.5;
		top -=1;
		bot -=1;
		yield;
	}
	loop(50) {
		ObjSprite2D_SetDestRect(portrait, left, top, right, bot);
		left += 6;
		right += 6;
		top -=3;
		bot -=3;
		yield;
	}
	Obj_Delete(portrait);
}

task scroll666(aaa) {
	let scrollTex = 0;
	loop {
		ObjSprite2D_SetSourceRect(aaa,0,0-scrollTex,540,870-scrollTex);
		scrollTex += 0.5;
		yield;
	}
}

task couleur666(aaa) {
	let scrollTex1 = 125;
	let scrollTex2 = 125;
	let scrollTex3 = 125;
	loop {
	while(scrollTex1>100) {
		ObjRender_SetColor(aaa,scrollTex3,scrollTex1,scrollTex2);
		scrollTex1 -= 0.5;
		scrollTex2 -= 0.5;
		scrollTex3 -= 0.5;
		yield;
	}
	wait(120);
	while(scrollTex1<125) {
		ObjRender_SetColor(aaa,scrollTex3,scrollTex1,scrollTex2);
		scrollTex1 += 0.5;
		scrollTex2 += 0.5;
		scrollTex3 += 0.5;
		yield;
	}
	}
}


function renderSpellCard3 {
	// background
	let CSD = GetCurrentScriptDirectory;
	let texSpellCard = CSD ~ "img/SpellCardBoss3.png";
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(obj,21); 
	ObjPrim_SetTexture(obj,texSpellCard); 
	ObjSprite2D_SetSourceRect(obj,0,0,540,870);
	ObjSprite2D_SetDestRect(obj,0,0,GetStgFrameWidth,560);
	scroll3(obj);
	couleur3(obj);
	Apparition3;
}

task Apparition3 {
	let CSD = GetCurrentScriptDirectory;
	let texSpellCard = CSD ~ "img/VoyanteNormal.png";
	let portrait = ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(portrait,21);
	ObjPrim_SetTexture(portrait, texSpellCard);
	ObjRender_SetBlendType(portrait, BLEND_ALPHA);
	ObjSprite2D_SetSourceRect(portrait, 0, 0, 720, 720);
	ObjRender_SetColor(portrait,222,222,222);
	let left = -500;
	let right = 0;
	let top = 200;
	let bot = 700;
	ObjSprite2D_SetDestRect(portrait, left, top, right, bot);
	loop(50) {
		ObjSprite2D_SetDestRect(portrait, left, top, right, bot);
		left += 6;
		right += 6;
		top -=3;
		bot -=3;
		yield;
	}
	loop(100) {
		ObjSprite2D_SetDestRect(portrait, left, top, right, bot);
		left += 2.5;
		right += 2.5;
		top -=1;
		bot -=1;
		yield;
	}
	loop(50) {
		ObjSprite2D_SetDestRect(portrait, left, top, right, bot);
		left += 6;
		right += 6;
		top -=3;
		bot -=3;
		yield;
	}
	Obj_Delete(portrait);
}

task scroll3(aaa) {
	let scrollTex = 0;
	loop {
		ObjSprite2D_SetSourceRect(aaa,0,0-scrollTex,540,870-scrollTex);
		scrollTex += 0.5;
		yield;
	}
}

task couleur3(aaa) {
	let scrollTex1 = 125;
	let scrollTex2 = 125;
	let scrollTex3 = 125;
	loop {
	while(scrollTex1>100) {
		ObjRender_SetColor(aaa,scrollTex3,scrollTex1,scrollTex2);
		scrollTex1 -= 0.5;
		scrollTex2 -= 0.5;
		scrollTex3 -= 0.5;
		yield;
	}
	wait(120);
	while(scrollTex1<125) {
		ObjRender_SetColor(aaa,scrollTex3,scrollTex1,scrollTex2);
		scrollTex1 += 0.5;
		scrollTex2 += 0.5;
		scrollTex3 += 0.5;
		yield;
	}
	}
}

function renderSpellCardMidBoss2 {
	// background
	let CSD = GetCurrentScriptDirectory;
	let texSpellCard = CSD ~ "img/SpellCardMidBoss2.png";
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(obj,21); 
	ObjPrim_SetTexture(obj,texSpellCard); 
	ObjSprite2D_SetSourceRect(obj,0,0,540,870);
	ObjSprite2D_SetDestRect(obj,0,0,GetStgFrameWidth,560);
	scrollMidBoss2(obj);
	couleurMidBoss2(obj);
	ApparitionMidBoss2;
}

task scrollMidBoss2(aaa) {
	let scrollTex = 0;
	loop {
		ObjSprite2D_SetSourceRect(aaa,0+scrollTex,0+scrollTex,540-scrollTex,1000-scrollTex);
		scrollTex -= 0.25;
		yield;
	}
}

task couleurMidBoss2(aaa) {
	let scrollTex1 = 125;
	let scrollTex2 = 125;
	let scrollTex3 = 125;
	loop {
	while(scrollTex1>100) {
		ObjRender_SetColor(aaa,scrollTex3,scrollTex1,scrollTex2);
		scrollTex1 -= 0.5;
		scrollTex2 -= 0.5;
		scrollTex3 -= 0.5;
		yield;
	}
	wait(120);
	while(scrollTex1<125) {
		ObjRender_SetColor(aaa,scrollTex3,scrollTex1,scrollTex2);
		scrollTex1 += 0.5;
		scrollTex2 += 0.5;
		scrollTex3 += 0.5;
		yield;
	}
	}
}

task ApparitionMidBoss2 {
	let CSD = GetCurrentScriptDirectory;
	let texSpellCard = CSD ~ "img/FeeDuNeant.png";
	let portrait = ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(portrait,21);
	ObjPrim_SetTexture(portrait, texSpellCard);
	ObjRender_SetBlendType(portrait, BLEND_ALPHA);
	ObjSprite2D_SetSourceRect(portrait, 0, 0, 720, 720);
	ObjRender_SetColor(portrait,222,222,222);
	let left = -500;
	let right = 0;
	let top = 200;
	let bot = 700;
	ObjSprite2D_SetDestRect(portrait, left, top, right, bot);
	loop(50) {
		ObjSprite2D_SetDestRect(portrait, left, top, right, bot);
		left += 6;
		right += 6;
		top -=3;
		bot -=3;
		yield;
	}
	loop(100) {
		ObjSprite2D_SetDestRect(portrait, left, top, right, bot);
		left += 2.5;
		right += 2.5;
		top -=1;
		bot -=1;
		yield;
	}
	loop(50) {
		ObjSprite2D_SetDestRect(portrait, left, top, right, bot);
		left += 6;
		right += 6;
		top -=3;
		bot -=3;
		yield;
	}
	Obj_Delete(portrait);
}

function renderSpellCard2 {
	// background
	let CSD = GetCurrentScriptDirectory;
	let texSpellCard = CSD ~ "img/SpellCardBoss2.png";
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(obj,21); 
	ObjPrim_SetTexture(obj,texSpellCard); 
	ObjSprite2D_SetSourceRect(obj,0,0,540,870);
	ObjSprite2D_SetDestRect(obj,0,0,GetStgFrameWidth,560);
	scroll2(obj);
	couleur2(obj);
	Apparition2;
}

task Apparition2 {
	let CSD = GetCurrentScriptDirectory;
	let texSpellCard = CSD ~ "img/FeeDesFlammesNormal.png";
	let portrait = ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(portrait,21);
	ObjPrim_SetTexture(portrait, texSpellCard);
	ObjRender_SetBlendType(portrait, BLEND_ALPHA);
	ObjSprite2D_SetSourceRect(portrait, 0, 0, 720, 720);
	ObjRender_SetColor(portrait,222,222,222);
	let left = -500;
	let right = 0;
	let top = 200;
	let bot = 700;
	ObjSprite2D_SetDestRect(portrait, left, top, right, bot);
	loop(50) {
		ObjSprite2D_SetDestRect(portrait, left, top, right, bot);
		left += 6;
		right += 6;
		top -=3;
		bot -=3;
		yield;
	}
	loop(100) {
		ObjSprite2D_SetDestRect(portrait, left, top, right, bot);
		left += 2.5;
		right += 2.5;
		top -=1;
		bot -=1;
		yield;
	}
	loop(50) {
		ObjSprite2D_SetDestRect(portrait, left, top, right, bot);
		left += 6;
		right += 6;
		top -=3;
		bot -=3;
		yield;
	}
	Obj_Delete(portrait);
}

task scroll2(aaa) {
	let scrollTex = 0;
	loop {
		ObjSprite2D_SetSourceRect(aaa,0,0-scrollTex,540,870-scrollTex);
		scrollTex += 0.5;
		yield;
	}
}

task couleur2(aaa) {
	let scrollTex1 = 125;
	let scrollTex2 = 125;
	let scrollTex3 = 125;
	loop {
	while(scrollTex1>100) {
		ObjRender_SetColor(aaa,scrollTex3,scrollTex1,scrollTex2);
		scrollTex1 -= 0.5;
		scrollTex2 -= 0.5;
		scrollTex3 -= 0.5;
		yield;
	}
	wait(120);
	while(scrollTex1<125) {
		ObjRender_SetColor(aaa,scrollTex3,scrollTex1,scrollTex2);
		scrollTex1 += 0.5;
		scrollTex2 += 0.5;
		scrollTex3 += 0.5;
		yield;
	}
	}
}

function renderSpellCard1 {
	// background
	let CSD = GetCurrentScriptDirectory;
	let texSpellCard = CSD ~ "img/SpellCardBoss1.png";
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(obj,21); 
	ObjPrim_SetTexture(obj,texSpellCard); 
	ObjSprite2D_SetSourceRect(obj,0,0,540,870);
	ObjSprite2D_SetDestRect(obj,0,0,GetStgFrameWidth,560);
	couleur1(obj);
	Apparition1;
}

task Apparition1 {
	let CSD = GetCurrentScriptDirectory;
	let texSpellCard = CSD ~ "img/YokaiFeuillesMortesNormal.png";
	let portrait = ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(portrait,21);
	ObjPrim_SetTexture(portrait, texSpellCard);
	ObjRender_SetBlendType(portrait, BLEND_ALPHA);
	ObjSprite2D_SetSourceRect(portrait, 0, 0, 720, 720);
	ObjRender_SetColor(portrait,222,222,222);
	let left = -500;
	let right = 0;
	let top = 200;
	let bot = 700;
	ObjSprite2D_SetDestRect(portrait, left, top, right, bot);
	loop(50) {
		ObjSprite2D_SetDestRect(portrait, left, top, right, bot);
		left += 6;
		right += 6;
		top -=3;
		bot -=3;
		yield;
	}
	loop(100) {
		ObjSprite2D_SetDestRect(portrait, left, top, right, bot);
		left += 2.5;
		right += 2.5;
		top -=1;
		bot -=1;
		yield;
	}
	loop(50) {
		ObjSprite2D_SetDestRect(portrait, left, top, right, bot);
		left += 6;
		right += 6;
		top -=3;
		bot -=3;
		yield;
	}
	Obj_Delete(portrait);
}

task couleur1(aaa) {
	let scrollTex1 = 125;
	let scrollTex2 = 125;
	let scrollTex3 = 125;
	loop {
	while(scrollTex1>100) {
		ObjRender_SetColor(aaa,scrollTex3,scrollTex1,scrollTex2);
		scrollTex1 -= 0.5;
		scrollTex2 -= 0.5;
		scrollTex3 -= 0.5;
		yield;
	}
	wait(120);
	while(scrollTex1<125) {
		ObjRender_SetColor(aaa,scrollTex3,scrollTex1,scrollTex2);
		scrollTex1 += 0.5;
		scrollTex2 += 0.5;
		scrollTex3 += 0.5;
		yield;
	}
	}
}

function overlay {
	let scrollTex = 0;
	// overlay 
	let overlayObj = ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(overlayObj,21); 
	ObjPrim_SetTexture(overlayObj,overlay); 
	ObjRender_SetBlendType(overlayObj,BLEND_ADD_ARGB);
	ObjRender_SetAlpha(overlayObj,200);
	ObjSprite2D_SetSourceRect(overlayObj,0,0,512,512);
	ObjSprite2D_SetDestRect(overlayObj,0,0,GetStgFrameWidth,GetStgFrameHeight);
	
	// As long as the boss is alive, scroll the overlay diagonally towards bottom right.
	loop {
		ObjSprite2D_SetSourceRect(overlayObj,0-scrollTex,0-scrollTex,512-scrollTex,512-scrollTex);
		scrollTex += 2;
		yield;
	}
	Obj_Delete(overlayObj);
}

function DialogueText(posX,posY,controltype,waittime,fontsize,message){
	let objTxt = ObjText_Create;
	let alpha = 0;
	
	ObjRender_SetAlpha(objTxt,alpha);
	ObjRender_SetPosition(objTxt,posX,posY,0);
	
	ObjText_SetText(objTxt,message);
	ObjText_SetFontSize(objTxt,fontsize);
	ObjText_SetFontType(objTxt,"Cirno");
	ObjText_SetFontColorTop(objTxt,0,0,0);
	ObjText_SetFontColorBottom(objTxt,0,0,0);
	ObjText_SetFontBorderType(objTxt,BORDER_NONE);
	ObjText_SetHorizontalAlignment(objTxt, ALIGNMENT_CENTER);
	ObjText_SetMaxWidth(objTxt, 400);
	Obj_SetRenderPriority(objTxt, 100);
	
	wait(5);
	
	loop(5){
		alpha+=255/5;
		ObjRender_SetAlpha(objTxt,alpha);
	yield;}
	
	if(controltype == "TIMED"){
		loop(waittime){yield;}	
	}
	
	if(controltype == "CONTROL"){
		while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){yield;}
	}
	
	loop(5){
		alpha-=255/5;
		ObjRender_SetAlpha(objTxt,alpha);
	yield;}
	
	Obj_Delete(objTxt);

}

function DialogueBubble(vertangle,posX,posY,Yscale,lengthtimes,controltype,waittime){
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	let obj2 = ObjPrim_Create(OBJ_SPRITE_2D);
	let obj3 = ObjPrim_Create(OBJ_SPRITE_2D);
	let obj4 = ObjPrim_Create(OBJ_SPRITE_2D);
	let obj5 = ObjPrim_Create(OBJ_SPRITE_2D);
	let obj6 = ObjPrim_Create(OBJ_SPRITE_2D);
	
	ObjPrim_SetTexture(obj, GetCurrentScriptDirectory~"./img/balloon.png");
	ObjSprite2D_SetSourceRect(obj,128, 2, 228, 127);
	ObjRender_SetScaleXYZ(obj,1,Yscale,0);
	Obj_SetRenderPriorityI(obj,100);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetPosition(obj,posX,posY,0);
	ObjRender_SetAngleX(obj,90);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
		
	ObjPrim_SetTexture(obj2, GetCurrentScriptDirectory~"./img/balloon.png");
	ObjSprite2D_SetSourceRect(obj2,1, 1, 126, 127);
	ObjRender_SetScaleXYZ(obj2,1,Yscale,0);
	Obj_SetRenderPriorityI(obj2,100);
	ObjSprite2D_SetDestCenter(obj2);
	ObjRender_SetPosition(obj2,posX+80,posY,0);
	ObjRender_SetAngleX(obj2,90);
	ObjRender_SetBlendType(obj2,BLEND_ALPHA);
	
	if(lengthtimes>1){
		ObjPrim_SetTexture(obj3, GetCurrentScriptDirectory~"./img/balloon.png");
		ObjSprite2D_SetSourceRect(obj3,1, 1, 126, 127);
		ObjRender_SetScaleXYZ(obj3,1,Yscale,0);
		Obj_SetRenderPriorityI(obj3,100);
		ObjSprite2D_SetDestCenter(obj3);
		ObjRender_SetPosition(obj3,posX+110,posY,0);
		ObjRender_SetAngleX(obj3,90);
		ObjRender_SetBlendType(obj3,BLEND_ALPHA);
	}	
	if(lengthtimes>2){
		ObjPrim_SetTexture(obj4, GetCurrentScriptDirectory~"./img/balloon.png");
		ObjSprite2D_SetSourceRect(obj4,1, 1, 126, 127);
		ObjRender_SetScaleXYZ(obj4,1,Yscale,0);
		Obj_SetRenderPriorityI(obj4,100);
		ObjSprite2D_SetDestCenter(obj4);
		ObjRender_SetPosition(obj4,posX+140,posY,0);
		ObjRender_SetAngleX(obj4,90);
		ObjRender_SetBlendType(obj4,BLEND_ALPHA);
	}
	if(lengthtimes>3){
		ObjPrim_SetTexture(obj5, GetCurrentScriptDirectory~"./img/balloon.png");
		ObjSprite2D_SetSourceRect(obj5,1, 1, 126, 127);
		ObjRender_SetScaleXYZ(obj5,1,Yscale,0);
		Obj_SetRenderPriorityI(obj5,100);
		ObjSprite2D_SetDestCenter(obj5);
		ObjRender_SetPosition(obj5,posX+170,posY,0);
		ObjRender_SetAngleX(obj5,90);
		ObjRender_SetBlendType(obj5,BLEND_ALPHA);
	}
	if(lengthtimes>4){
		ObjPrim_SetTexture(obj6, GetCurrentScriptDirectory~"./img/balloon.png");
		ObjSprite2D_SetSourceRect(obj6,1, 1, 126, 127);
		ObjRender_SetScaleXYZ(obj6,1,Yscale,0);
		Obj_SetRenderPriorityI(obj6,100);
		ObjSprite2D_SetDestCenter(obj6);
		ObjRender_SetPosition(obj6,posX+200,posY,0);
		ObjRender_SetAngleX(obj6,90);
		ObjRender_SetBlendType(obj6,BLEND_ALPHA);
	}
	
	let dif = -(90-vertangle);
	let angleX = 90;
	
	loop(10){
		angleX+=dif/10;
		ObjRender_SetAngleX(obj,angleX);
		ObjRender_SetAngleX(obj2,angleX);
		if(lengthtimes>1){ObjRender_SetAngleX(obj3,angleX);}
		if(lengthtimes>2){ObjRender_SetAngleX(obj4,angleX);}
		if(lengthtimes>3){ObjRender_SetAngleX(obj5,angleX);}
		if(lengthtimes>4){ObjRender_SetAngleX(obj6,angleX);}
	yield;}
	
	if(controltype == "TIMED"){
		loop(waittime){yield;}	
	}
	
	if(controltype == "CONTROL"){
		while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){yield;}
	}
	
	loop(10){
		angleX+=dif/10;
		ObjRender_SetAngleX(obj,angleX);
		ObjRender_SetAngleX(obj2,angleX);
		if(lengthtimes>1){ObjRender_SetAngleX(obj3,angleX);}
		if(lengthtimes>2){ObjRender_SetAngleX(obj4,angleX);}
		if(lengthtimes>3){ObjRender_SetAngleX(obj5,angleX);}
		if(lengthtimes>4){ObjRender_SetAngleX(obj6,angleX);}
	yield;}
	
	Obj_Delete(obj);
	Obj_Delete(obj2);
	Obj_Delete(obj3);
	Obj_Delete(obj4);
	Obj_Delete(obj5);
	Obj_Delete(obj6);
}

function DialogueBubbleEnnemi(vertangle,posX,posY,Yscale,lengthtimes,controltype,waittime){
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	let obj2 = ObjPrim_Create(OBJ_SPRITE_2D);
	let obj3 = ObjPrim_Create(OBJ_SPRITE_2D);
	let obj4 = ObjPrim_Create(OBJ_SPRITE_2D);
	let obj5 = ObjPrim_Create(OBJ_SPRITE_2D);
	let obj6 = ObjPrim_Create(OBJ_SPRITE_2D);
	
	ObjPrim_SetTexture(obj, GetCurrentScriptDirectory~"./img/balloon.png");
	ObjSprite2D_SetSourceRect(obj,128, 2, 228, 127);
	ObjRender_SetScaleXYZ(obj,1,Yscale,0);
	Obj_SetRenderPriorityI(obj,100);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetPosition(obj,posX+250,posY,0);
	ObjRender_SetAngleX(obj,90);
	ObjRender_SetAngleY(obj,180);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
		
	ObjPrim_SetTexture(obj2, GetCurrentScriptDirectory~"./img/balloon.png");
	ObjSprite2D_SetSourceRect(obj2,1, 1, 126, 127);
	ObjRender_SetScaleXYZ(obj2,1,Yscale,0);
	Obj_SetRenderPriorityI(obj2,100);
	ObjSprite2D_SetDestCenter(obj2);
	ObjRender_SetPosition(obj2,posX+170,posY,0);
	ObjRender_SetAngleX(obj2,90);
	ObjRender_SetAngleY(obj2,180);
	ObjRender_SetBlendType(obj2,BLEND_ALPHA);
	
	if(lengthtimes>1){
		ObjPrim_SetTexture(obj3, GetCurrentScriptDirectory~"./img/balloon.png");
		ObjSprite2D_SetSourceRect(obj3,1, 1, 126, 127);
		ObjRender_SetScaleXYZ(obj3,1,Yscale,0);
		Obj_SetRenderPriorityI(obj3,100);
		ObjSprite2D_SetDestCenter(obj3);
		ObjRender_SetPosition(obj3,posX+140,posY,0);
		ObjRender_SetAngleX(obj3,90);
		ObjRender_SetAngleY(obj3,180);
		ObjRender_SetBlendType(obj3,BLEND_ALPHA);
	}	
	if(lengthtimes>2){
		ObjPrim_SetTexture(obj4, GetCurrentScriptDirectory~"./img/balloon.png");
		ObjSprite2D_SetSourceRect(obj4,1, 1, 126, 127);
		ObjRender_SetScaleXYZ(obj4,1,Yscale,0);
		Obj_SetRenderPriorityI(obj4,100);
		ObjSprite2D_SetDestCenter(obj4);
		ObjRender_SetPosition(obj4,posX+110,posY,0);
		ObjRender_SetAngleX(obj4,90);
		ObjRender_SetAngleY(obj4,180);
		ObjRender_SetBlendType(obj4,BLEND_ALPHA);
	}
	if(lengthtimes>3){
		ObjPrim_SetTexture(obj5, GetCurrentScriptDirectory~"./img/balloon.png");
		ObjSprite2D_SetSourceRect(obj5,1, 1, 126, 127);
		ObjRender_SetScaleXYZ(obj5,1,Yscale,0);
		Obj_SetRenderPriorityI(obj5,100);
		ObjSprite2D_SetDestCenter(obj5);
		ObjRender_SetPosition(obj5,posX+90,posY,0);
		ObjRender_SetAngleX(obj5,90);
		ObjRender_SetAngleY(obj5,180);
		ObjRender_SetBlendType(obj5,BLEND_ALPHA);
	}
	if(lengthtimes>4){
		ObjPrim_SetTexture(obj6, GetCurrentScriptDirectory~"./img/balloon.png");
		ObjSprite2D_SetSourceRect(obj6,1, 1, 126, 127);
		ObjRender_SetScaleXYZ(obj6,1,Yscale,0);
		Obj_SetRenderPriorityI(obj6,100);
		ObjSprite2D_SetDestCenter(obj6);
		ObjRender_SetPosition(obj6,posX+60,posY,0);
		ObjRender_SetAngleX(obj6,90);
		ObjRender_SetAngleY(obj6,180);
		ObjRender_SetBlendType(obj6,BLEND_ALPHA);
	}
	
	let dif = -(90-vertangle);
	let angleX = 90;
	
	loop(10){
		angleX+=dif/10;
		ObjRender_SetAngleX(obj,angleX);
		ObjRender_SetAngleX(obj2,angleX);
		if(lengthtimes>1){ObjRender_SetAngleX(obj3,angleX);}
		if(lengthtimes>2){ObjRender_SetAngleX(obj4,angleX);}
		if(lengthtimes>3){ObjRender_SetAngleX(obj5,angleX);}
		if(lengthtimes>4){ObjRender_SetAngleX(obj6,angleX);}
	yield;}
	
	if(controltype == "TIMED"){
		loop(waittime){yield;}	
	}
	
	if(controltype == "CONTROL"){
		while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){yield;}
	}
	
	loop(10){
		angleX+=dif/10;
		ObjRender_SetAngleX(obj,angleX);
		ObjRender_SetAngleX(obj2,angleX);
		if(lengthtimes>1){ObjRender_SetAngleX(obj3,angleX);}
		if(lengthtimes>2){ObjRender_SetAngleX(obj4,angleX);}
		if(lengthtimes>3){ObjRender_SetAngleX(obj5,angleX);}
		if(lengthtimes>4){ObjRender_SetAngleX(obj6,angleX);}
	yield;}
	
	Obj_Delete(obj);
	Obj_Delete(obj2);
	Obj_Delete(obj3);
	Obj_Delete(obj4);
	Obj_Delete(obj5);
	Obj_Delete(obj6);
}

//pouvoir
let pouvoir = 0;
function pouvoirs(n)
{
	pouvoir = n
}

//pouvoir
let teste = 0;
function test(n)
{
	teste = n
}

//wait n frames
function wait(n) 
{
	loop (n) {
		yield;
	}
}

//gives a random integer from a to b (inclusive)
function randInt(a, b)
{
	return floor(rand(a, b + 1));
}


//gives angle to player
function angleToPlayer(x, y) 
{
	return atan2(GetPlayerY - y, GetPlayerX - x);
}


//get angle to player from boss location, bossX/bossY must be in common data
function bossAngleToPlayer() 
{
	return atan2(GetPlayerY - GetCommonData("bossY", 0), GetPlayerX - GetCommonData("bossX", 0));
}

//gives angle from obj1 to obj2
function angle(obj1, obj2)
{
	return atan2(ObjMove_GetY(obj2) - ObjMove_GetY(obj1), ObjMove_GetX(obj2) - ObjMove_GetX(obj1));
}

//gives the angle from point one to point two
function anglePoints(x1, y1, x2, y2)
{
	return atan2(y2 - y1, x2 - x1);;
}

//gives distance bewteen two objects
function distance(obj1, obj2)
{
	return (((ObjMove_GetX(obj2) - ObjMove_GetX(obj1)) ^ 2 + (ObjMove_GetY(obj2) - ObjMove_GetY(obj1)) ^ 2) ^ (1 / 2));
}

//gives the distance between two points
function distancePoints(x1, y1, x2, y2)
{
	return (((x2 - x1) ^ 2 + (y2 - y1) ^ 2) ^ (1 / 2))
}

//get center x position
function getCenterX
{
    return GetStgFrameWidth / 2;
}
 
//get center y position
function getCenterY
{
     return GetStgFrameHeight / 2;
 }

 //gives number of digits in an integer
function numDigits(n)
{
	let count = 0;
	if (n / 10 > 0) {
		return numDigits(n / 10) + 1;
	} else {
		return 1;
	}
}

 
 
 
 