task CreateStageEnemyBall(x, y, speedE, angleE) {
let shootSFX = GetCurrentScriptDirectory ~ "SFX/ATTACK4.wav";
let deadSFX = GetCurrentScriptDirectory ~ "SFX/BEAT.mp3";
let animFrame = 0; 
let animFrame2 = 0;
 let Xmin = -32;
    let Xmax = GetStgFrameWidth + 32;
    let Ymin = -32; 
    let Ymax = GetStgFrameHeight + 32;
	let count = 0; 
    let objEnemy3 = ObjEnemy_Create(OBJ_ENEMY);
    TInitialize;
   task TInitialize 
    {
        LoadSound(shootSFX);
        
        LoadSound(deadSFX);
     
        
        ObjEnemy_Regist(objEnemy3);
        ObjEnemy_SetLife(objEnemy3, 200);
        
        ObjEnemy_SetDamageRate(objEnemy3, 200, 200);
        ObjMove_SetPosition(objEnemy3, x, y);
        ObjMove_SetAngle(objEnemy3, angleE);
        ObjMove_SetSpeed(objEnemy3, speedE);
        ObjMove_SetDestAtSpeed(objEnemy3, x , 150, 3); //movement function
        TDrawLoop;
        TMainLoop;
        TFinalize;
        wait(400);
        
        let e_dir = GetAngleToPlayer(objEnemy3) > 192;
        ObjMove_AddPatternA2(objEnemy3, 0, 0, [+40, 220][e_dir], 6/120, 0, 6);
        
        //TFinalize;
    }
	function GetEnemyX{
return ObjMove_GetX(objEnemy3);
}
	function GetEnemyY{
return ObjMove_GetY(objEnemy3);
}

     task TMainLoop {
        while(ObjEnemy_GetInfo(objEnemy3, INFO_LIFE) > 0) {
            ObjEnemy_SetIntersectionCircleToShot(objEnemy3, ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3), 32); 
            ObjEnemy_SetIntersectionCircleToPlayer(objEnemy3, ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3), 8);
            if (count % 60 == 30) {bulletA;}
            count++;
			if (count == 1000){DeleteShotAll(TYPE_CHILD, TYPE_ITEM);	}
			
			
		
		            if (ObjMove_GetX(objEnemy3) < Xmin || ObjMove_GetY(objEnemy3) > Xmax || ObjMove_GetY(objEnemy3) < Ymin || ObjMove_GetY(objEnemy3) > Ymax) {
                Obj_Delete(objEnemy3); }

            yield;
        }
		
		
		}
    

		
    
    task bulletA{
	
	if (GetCommonData("Difficulty", 3) == 3){
	

   let angleT = rand(ObjMove_GetX(objEnemy3),ObjMove_GetY(objEnemy3));
   
    loop(2){
	
     ascent(i in 0..20){
	 PlaySE(shootSFX);
        CreateShotA1(ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3), 1 - i/4, angleT,DS_LIGHT_RED, 5);
        angleT += 360/40;
		
    }
 }
 
 }
 	if (GetCommonData("Difficulty", 2) == 2){
	

   let angleT = rand(ObjMove_GetX(objEnemy3),ObjMove_GetY(objEnemy3));
   
    loop(2){
	
     ascent(i in 0..15){
	 PlaySE(shootSFX);
        CreateShotA1(ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3), 1 - i/4, angleT,DS_LIGHT_RED, 5);
        angleT += 360/30;
		
    }
 }
 
 }
 
  	if (GetCommonData("Difficulty", 1) == 1){
	

   let angleT = rand(ObjMove_GetX(objEnemy3),ObjMove_GetY(objEnemy3));
   
    loop(2){
	
     ascent(i in 0..12){
	 PlaySE(shootSFX);
        CreateShotA1(ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3), 1 - i/4, angleT,DS_LIGHT_RED, 5);
        angleT += 360/24;
		
    }
 }
 
 }
 
   	if (GetCommonData("Difficulty", 0) == 0){
	

   let angleT = rand(ObjMove_GetX(objEnemy3),ObjMove_GetY(objEnemy3));
   
    loop(2){
	
     ascent(i in 0..8){
	 PlaySE(shootSFX);
        CreateShotA1(ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3), 1 - i/4, angleT,DS_LIGHT_RED, 5);
        angleT += 360/16;
		
    }
 }
 
 }
 }
 
 task TExplosion{
    let path = GetCurrentScriptDirectory() ~ "sprite/pow.png";
    let obj = ObjPrim_Create(OBJ_SPRITE_2D);
    ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);
    Obj_SetRenderPriority(obj, 0.60);
    ObjPrim_SetTexture(obj, path);
    ObjSprite2D_SetSourceRect(obj, 0, 0, 100, 100);
    ObjSprite2D_SetDestRect(obj, -32, -32, 32, 32);
 
    let alpha = 230;
    let scale = 0.5;
    loop(12)
    {
        scale += 0.2;
        alpha -= 8;
        ObjRender_SetColor(obj, alpha, alpha, alpha);
        ObjRender_SetPosition(obj, GetEnemyX, GetEnemyY, 0);
        ObjRender_SetScaleXYZ(obj, scale, scale, 0.5);
        yield;
    }
    Obj_Delete(obj);
}

        	
    
	
	task TDrawLoop {
	let imgenemy = GetCurrentScriptDirectory() ~ "sprite/orbenemy1.png";
    ObjPrim_SetTexture(objEnemy3, imgenemy);
    ObjSprite2D_SetSourceRect(objEnemy3, 0, 0, 116, 106);
	ObjRender_SetScaleXYZ(objEnemy3, 0.5, 0.5, 0);
    ObjSprite2D_SetDestCenter(objEnemy3);
	}

task TFinalize 
    {
        //if(ObjEnemy_GetInfo(objEnemy3, INFO_LIFE) == 0) 
        while(ObjEnemy_GetInfo(objEnemy3, INFO_LIFE) > 0)//this checks if the enemy has still life remaining
        {
            yield;
        }

        if(!Obj_IsDeleted(objEnemy3))//This checks if the enemy is already deleted by other means like leaving the screen and getting killed through a differnt task and no effect is needed
        {
            PlaySE(deadSFX);
            TExplosion;
            wait(12);
            Obj_Delete(objEnemy3);
            DeleteShotInCircle(TYPE_CHILD, TYPE_ITEM, ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3), 200);
            yield;
        }
    }
	}
	
	
	//------------------------------
	
	task CreateStageEnemyBall2(x, y, speedE, angleE) {
let shootSFX = GetCurrentScriptDirectory ~ "SFX/ATTACK4.wav";
let deadSFX = GetCurrentScriptDirectory ~ "SFX/BEAT.mp3";
let animFrame = 0; 
let animFrame2 = 0;
 let Xmin = -32;
    let Xmax = GetStgFrameWidth + 32;
    let Ymin = -32; 
    let Ymax = GetStgFrameHeight + 32;
	let count = 0; 
    let objEnemy3 = ObjEnemy_Create(OBJ_ENEMY);
    TInitialize;
   task TInitialize 
    {
        LoadSound(shootSFX);
        
        LoadSound(deadSFX);
     
        
        ObjEnemy_Regist(objEnemy3);
        ObjEnemy_SetLife(objEnemy3, 200);
        
        ObjEnemy_SetDamageRate(objEnemy3, 200, 200);
        ObjMove_SetPosition(objEnemy3, x, y);
        ObjMove_SetAngle(objEnemy3, angleE);
        ObjMove_SetSpeed(objEnemy3, speedE);
        ObjMove_SetDestAtSpeed(objEnemy3, x , 150, 3); //movement function
        TDrawLoop;
        TMainLoop;
        TFinalize;
        wait(400);
        
        let e_dir = GetAngleToPlayer(objEnemy3) > 192;
        ObjMove_AddPatternA2(objEnemy3, 0, 0, [+40, 220][e_dir], 6/120, 0, 6);
        
        //TFinalize;
    }
	function GetEnemyX{
return ObjMove_GetX(objEnemy3);
}
	function GetEnemyY{
return ObjMove_GetY(objEnemy3);
}

     task TMainLoop {
        while(ObjEnemy_GetInfo(objEnemy3, INFO_LIFE) > 0) {
            ObjEnemy_SetIntersectionCircleToShot(objEnemy3, ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3), 32); 
            ObjEnemy_SetIntersectionCircleToPlayer(objEnemy3, ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3), 8);
            if (count % 60 == 30) {bulletA;}
            count++;
			if (count == 1000){DeleteShotAll(TYPE_CHILD, TYPE_ITEM);	}
			
			
		
		            if (ObjMove_GetX(objEnemy3) < Xmin || ObjMove_GetY(objEnemy3) > Xmax || ObjMove_GetY(objEnemy3) < Ymin || ObjMove_GetY(objEnemy3) > Ymax) {
                Obj_Delete(objEnemy3); }

            yield;
        }
		
		
		}
    

		
    
    task bulletA{
	
	if (GetCommonData("Difficulty", 3) == 3){
   let angleT = rand(ObjMove_GetX(objEnemy3),ObjMove_GetY(objEnemy3)-90);
   
    loop(2){
	
     ascent(i in 0..20){
	 PlaySE(shootSFX);
        CreateShotA1(ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3), 1 - i/6, angleT,DS_LIGHT_BLUE, 5);
        angleT += 360/40;
		
    }
 }
 }
 
 	if (GetCommonData("Difficulty", 2) == 2){
   let angleT = rand(ObjMove_GetX(objEnemy3),ObjMove_GetY(objEnemy3)-90);
   
    loop(2){
	
     ascent(i in 0..15){
	 PlaySE(shootSFX);
        CreateShotA1(ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3), 1 - i/6, angleT,DS_LIGHT_BLUE, 5);
        angleT += 360/30;
		
    }
 }
 }
  	if (GetCommonData("Difficulty", 1) == 1){
   let angleT = rand(ObjMove_GetX(objEnemy3),ObjMove_GetY(objEnemy3)-90);
   
    loop(2){
	
     ascent(i in 0..12){
	 PlaySE(shootSFX);
        CreateShotA1(ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3), 1 - i/6, angleT,DS_LIGHT_BLUE, 5);
        angleT += 360/24;
		
    }
 }
 }
   	if (GetCommonData("Difficulty", 0) == 0){
   let angleT = rand(ObjMove_GetX(objEnemy3),ObjMove_GetY(objEnemy3)-90);
   
    loop(2){
	
     ascent(i in 0..8){
	 PlaySE(shootSFX);
        CreateShotA1(ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3), 1 - i/6, angleT,DS_LIGHT_BLUE, 5);
        angleT += 360/16;
		
    }
 }
 }
 }
 
 task TExplosion{
    let path = GetCurrentScriptDirectory() ~ "sprite/pow.png";
    let obj = ObjPrim_Create(OBJ_SPRITE_2D);
    ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);
    Obj_SetRenderPriority(obj, 0.60);
    ObjPrim_SetTexture(obj, path);
    ObjSprite2D_SetSourceRect(obj, 0, 0, 100, 100);
    ObjSprite2D_SetDestRect(obj, -32, -32, 32, 32);
 
    let alpha = 230;
    let scale = 0.5;
    loop(12)
    {
        scale += 0.2;
        alpha -= 8;
        ObjRender_SetColor(obj, alpha, alpha, alpha);
        ObjRender_SetPosition(obj, GetEnemyX, GetEnemyY, 0);
        ObjRender_SetScaleXYZ(obj, scale, scale, 0.5);
        yield;
    }
    Obj_Delete(obj);
}

        	
    
	
	task TDrawLoop {
	let imgenemy = GetCurrentScriptDirectory() ~ "sprite/orbenemy2.png";
    ObjPrim_SetTexture(objEnemy3, imgenemy);
    ObjSprite2D_SetSourceRect(objEnemy3, 0, 0, 116, 106);
	ObjRender_SetScaleXYZ(objEnemy3, 0.5, 0.5, 0);
    ObjSprite2D_SetDestCenter(objEnemy3);
	}

task TFinalize 
    {
        //if(ObjEnemy_GetInfo(objEnemy3, INFO_LIFE) == 0) 
        while(ObjEnemy_GetInfo(objEnemy3, INFO_LIFE) > 0)//this checks if the enemy has still life remaining
        {
            yield;
        }

        if(!Obj_IsDeleted(objEnemy3))//This checks if the enemy is already deleted by other means like leaving the screen and getting killed through a differnt task and no effect is needed
        {
            PlaySE(deadSFX);
            TExplosion;
            wait(12);
            Obj_Delete(objEnemy3);
            DeleteShotInCircle(TYPE_CHILD, TYPE_ITEM, ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3),200);
            yield;
        }
    }
	}
	//-------------------------------
	task CreateStageEnemyBall3(x, y, speedE, angleE) {
let shootSFX = GetCurrentScriptDirectory ~ "SFX/ATTACK4.wav";
let deadSFX = GetCurrentScriptDirectory ~ "SFX/BEAT.mp3";
let animFrame = 0; 
let animFrame2 = 0;
 let Xmin = -32;
    let Xmax = GetStgFrameWidth + 32;
    let Ymin = -32; 
    let Ymax = GetStgFrameHeight + 32;
	let count = 0; 
    let objEnemy3 = ObjEnemy_Create(OBJ_ENEMY);
    TInitialize;
   task TInitialize 
    {
        LoadSound(shootSFX);
        
        LoadSound(deadSFX);
     
        
        ObjEnemy_Regist(objEnemy3);
        ObjEnemy_SetLife(objEnemy3, 200);
        
        ObjEnemy_SetDamageRate(objEnemy3, 200, 200);
        ObjMove_SetPosition(objEnemy3, x, y);
        ObjMove_SetAngle(objEnemy3, angleE);
        ObjMove_SetSpeed(objEnemy3, speedE);
        ObjMove_SetDestAtSpeed(objEnemy3, x , 150, 3); //movement function
        TDrawLoop;
        TMainLoop;
        TFinalize;
        wait(400);
        
        let e_dir = GetAngleToPlayer(objEnemy3) > 192;
        ObjMove_AddPatternA2(objEnemy3, 0, 0, [+40, 220][e_dir], 6/120, 0, 6);
        
        //TFinalize;
    }
	function GetEnemyX{
return ObjMove_GetX(objEnemy3);
}
	function GetEnemyY{
return ObjMove_GetY(objEnemy3);
}

     task TMainLoop {
        while(ObjEnemy_GetInfo(objEnemy3, INFO_LIFE) > 0) {
            ObjEnemy_SetIntersectionCircleToShot(objEnemy3, ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3), 32); 
            ObjEnemy_SetIntersectionCircleToPlayer(objEnemy3, ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3), 8);
            if (count % 60 == 30) {bulletA;}
            count++;
			if (count == 1000){DeleteShotAll(TYPE_CHILD, TYPE_ITEM);	}
			
			
		
		            if (ObjMove_GetX(objEnemy3) < Xmin || ObjMove_GetY(objEnemy3) > Xmax || ObjMove_GetY(objEnemy3) < Ymin || ObjMove_GetY(objEnemy3) > Ymax) {
                Obj_Delete(objEnemy3); }

            yield;
        }
		
		
		}
    

		
    
    task bulletA{
	
   	if (GetCommonData("Difficulty", 3) == 3){
   let angleT = rand(ObjMove_GetX(objEnemy3),ObjMove_GetY(objEnemy3)-90);
   
    loop(2){
	
     ascent(i in 0..20){
	 PlaySE(shootSFX);
        CreateShotA1(ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3), 1 - i/6, angleT,DS_LIGHT_YELLOW, 5);
        angleT += 360/40;
		
    }
 }
 }
    	if (GetCommonData("Difficulty", 2) == 2){
   let angleT = rand(ObjMove_GetX(objEnemy3),ObjMove_GetY(objEnemy3)-90);
   
    loop(2){
	
     ascent(i in 0..15){
	 PlaySE(shootSFX);
        CreateShotA1(ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3), 1 - i/6, angleT,DS_LIGHT_YELLOW, 5);
        angleT += 360/40;
		
    }
 }
 }
     	if (GetCommonData("Difficulty", 1) == 1){
   let angleT = rand(ObjMove_GetX(objEnemy3),ObjMove_GetY(objEnemy3)-90);
   
    loop(2){
	
     ascent(i in 0..12){
	 PlaySE(shootSFX);
        CreateShotA1(ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3), 1 - i/6, angleT,DS_LIGHT_YELLOW, 5);
        angleT += 360/24;
		
    }
 }
 }
      	if (GetCommonData("Difficulty", 0) == 0){
   let angleT = rand(ObjMove_GetX(objEnemy3),ObjMove_GetY(objEnemy3)-90);
   
    loop(2){
	
     ascent(i in 0..8){
	 PlaySE(shootSFX);
        CreateShotA1(ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3), 1 - i/6, angleT,DS_LIGHT_YELLOW, 5);
        angleT += 360/16;
		
    }
 }
 }
 }
 
 task TExplosion{
    let path = GetCurrentScriptDirectory() ~ "sprite/pow.png";
    let obj = ObjPrim_Create(OBJ_SPRITE_2D);
    ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);
    Obj_SetRenderPriority(obj, 0.60);
    ObjPrim_SetTexture(obj, path);
    ObjSprite2D_SetSourceRect(obj, 0, 0, 100, 100);
    ObjSprite2D_SetDestRect(obj, -32, -32, 32, 32);
 
    let alpha = 230;
    let scale = 0.5;
    loop(12)
    {
        scale += 0.2;
        alpha -= 8;
        ObjRender_SetColor(obj, alpha, alpha, alpha);
        ObjRender_SetPosition(obj, GetEnemyX, GetEnemyY, 0);
        ObjRender_SetScaleXYZ(obj, scale, scale, 0.5);
        yield;
    }
    Obj_Delete(obj);
}

        	
    
	
	task TDrawLoop {
	let imgenemy = GetCurrentScriptDirectory() ~ "sprite/orbenemy3.png";
    ObjPrim_SetTexture(objEnemy3, imgenemy);
    ObjSprite2D_SetSourceRect(objEnemy3, 0, 0, 116, 106);
	ObjRender_SetScaleXYZ(objEnemy3, 0.5, 0.5, 0);
    ObjSprite2D_SetDestCenter(objEnemy3);
	}

task TFinalize 
    {
        //if(ObjEnemy_GetInfo(objEnemy3, INFO_LIFE) == 0) 
        while(ObjEnemy_GetInfo(objEnemy3, INFO_LIFE) > 0)//this checks if the enemy has still life remaining
        {
            yield;
        }

        if(!Obj_IsDeleted(objEnemy3))//This checks if the enemy is already deleted by other means like leaving the screen and getting killed through a differnt task and no effect is needed
        {
            PlaySE(deadSFX);
            TExplosion;
            wait(12);
            Obj_Delete(objEnemy3);
            DeleteShotInCircle(TYPE_CHILD, TYPE_ITEM, ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3), 200);
            yield;
        }
    }
	}
	
	
	//-----------------
	
	task CreateStageEnemyBall4(x, y, speedE, angleE) {
let shootSFX = GetCurrentScriptDirectory ~ "SFX/ATTACK4.wav";
let deadSFX = GetCurrentScriptDirectory ~ "SFX/BEAT.mp3";
let animFrame = 0; 
let animFrame2 = 0;
 let Xmin = -32;
    let Xmax = GetStgFrameWidth + 32;
    let Ymin = -32; 
    let Ymax = GetStgFrameHeight + 32;
	let count = 0; 
    let objEnemy3 = ObjEnemy_Create(OBJ_ENEMY);
    TInitialize;
   task TInitialize 
    {
        LoadSound(shootSFX);
        
        LoadSound(deadSFX);
     
        
        ObjEnemy_Regist(objEnemy3);
        ObjEnemy_SetLife(objEnemy3, 200);
        
        ObjEnemy_SetDamageRate(objEnemy3, 200, 200);
        ObjMove_SetPosition(objEnemy3, x, y);
        ObjMove_SetAngle(objEnemy3, angleE);
        ObjMove_SetSpeed(objEnemy3, speedE);
        ObjMove_SetDestAtSpeed(objEnemy3, x , 150, 3); //movement function
        TDrawLoop;
        TMainLoop;
        TFinalize;
        wait(400);
        
        let e_dir = GetAngleToPlayer(objEnemy3) > 192;
        ObjMove_AddPatternA2(objEnemy3, 0, 0, [+40, 220][e_dir], 6/120, 0, 6);
        
        //TFinalize;
    }
	function GetEnemyX{
return ObjMove_GetX(objEnemy3);
}
	function GetEnemyY{
return ObjMove_GetY(objEnemy3);
}

     task TMainLoop {
        while(ObjEnemy_GetInfo(objEnemy3, INFO_LIFE) > 0) {
            ObjEnemy_SetIntersectionCircleToShot(objEnemy3, ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3), 32); 
            ObjEnemy_SetIntersectionCircleToPlayer(objEnemy3, ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3), 8);
            if (count % 60 == 30) {bulletA;}
            count++;
			if (count == 1000){DeleteShotAll(TYPE_CHILD, TYPE_ITEM);	}
			
			
		
		            if (ObjMove_GetX(objEnemy3) < Xmin || ObjMove_GetY(objEnemy3) > Xmax || ObjMove_GetY(objEnemy3) < Ymin || ObjMove_GetY(objEnemy3) > Ymax) {
                Obj_Delete(objEnemy3); }

            yield;
        }
		
		
		}
    

		
    
    task bulletA{
	
if (GetCommonData("Difficulty", 3) == 3){
   let angleT = rand(ObjMove_GetX(objEnemy3),ObjMove_GetY(objEnemy3)-90);
   
    loop(2){
	
     ascent(i in 0..20){
	 PlaySE(shootSFX);
        CreateShotA1(ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3), 1 - i/6, angleT,DS_LIGHT_PURPLE, 10);
        angleT += 360/40;
		
    }
 }
 }
 if (GetCommonData("Difficulty", 2) == 2){
   let angleT = rand(ObjMove_GetX(objEnemy3),ObjMove_GetY(objEnemy3)-90);
   
    loop(2){
	
     ascent(i in 0..15){
	 PlaySE(shootSFX);
        CreateShotA1(ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3), 1 - i/6, angleT,DS_LIGHT_PURPLE, 10);
        angleT += 360/30;
		
    }
 }
 }
  if (GetCommonData("Difficulty", 1) == 1){
   let angleT = rand(ObjMove_GetX(objEnemy3),ObjMove_GetY(objEnemy3)-90);
   
    loop(2){
	
     ascent(i in 0..12){
	 PlaySE(shootSFX);
        CreateShotA1(ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3), 1 - i/6, angleT,DS_LIGHT_PURPLE, 10);
        angleT += 360/24;
		
    }
 }
 }
   if (GetCommonData("Difficulty", 0) == 0){
   let angleT = rand(ObjMove_GetX(objEnemy3),ObjMove_GetY(objEnemy3)-90);
   
    loop(2){
	
     ascent(i in 0..8){
	 PlaySE(shootSFX);
        CreateShotA1(ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3), 1 - i/6, angleT,DS_LIGHT_PURPLE, 10);
        angleT += 360/16;
		
    }
 }
 }
 }
 
 task TExplosion{
    let path = GetCurrentScriptDirectory() ~ "sprite/pow.png";
    let obj = ObjPrim_Create(OBJ_SPRITE_2D);
    ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);
    Obj_SetRenderPriority(obj, 0.60);
    ObjPrim_SetTexture(obj, path);
    ObjSprite2D_SetSourceRect(obj, 0, 0, 100, 100);
    ObjSprite2D_SetDestRect(obj, -32, -32, 32, 32);
 
    let alpha = 230;
    let scale = 0.5;
    loop(12)
    {
        scale += 0.2;
        alpha -= 8;
        ObjRender_SetColor(obj, alpha, alpha, alpha);
        ObjRender_SetPosition(obj, GetEnemyX, GetEnemyY, 0);
        ObjRender_SetScaleXYZ(obj, scale, scale, 0.5);
        yield;
    }
    Obj_Delete(obj);
}

        	
    
	
	task TDrawLoop {
	let imgenemy = GetCurrentScriptDirectory() ~ "sprite/orbenemy4.png";
    ObjPrim_SetTexture(objEnemy3, imgenemy);
    ObjSprite2D_SetSourceRect(objEnemy3, 0, 0, 116, 106);
	ObjRender_SetScaleXYZ(objEnemy3, 0.5, 0.5, 0);
    ObjSprite2D_SetDestCenter(objEnemy3);
	}

task TFinalize 
    {
        //if(ObjEnemy_GetInfo(objEnemy3, INFO_LIFE) == 0) 
        while(ObjEnemy_GetInfo(objEnemy3, INFO_LIFE) > 0)//this checks if the enemy has still life remaining
        {
            yield;
        }

        if(!Obj_IsDeleted(objEnemy3))//This checks if the enemy is already deleted by other means like leaving the screen and getting killed through a differnt task and no effect is needed
        {
            PlaySE(deadSFX);
            TExplosion;
            wait(12);
            Obj_Delete(objEnemy3);
            DeleteShotInCircle(TYPE_CHILD, TYPE_ITEM, ObjMove_GetX(objEnemy3), ObjMove_GetY(objEnemy3), 200);
            yield;
        }
    }
	}
	
	