script_enemy_main
{

	//Oh god it's so nice to be able to use comments again
	let frame = 0;
	let alpha = 255;
	
	//DEFINE DEM IMAGES
	let bkg = GetCurrentScriptDirectory ~ "c6/enem2bg2.png";
	let bkg2 = GetCurrentScriptDirectory ~ "c6/enem2bg1.png";
	let bkg3 = GetCurrentScriptDirectory ~ "c6/c6shots.png";
	let boss = GetCurrentScriptDirectory ~ "c6/enem2.png";
	
    @Initialize
	{
		LoadUserShotData(GetCurrentScriptDirectory ~ "c6/c6shots.txt");
		LoadGraphic(bkg);
		LoadGraphic(bkg2);
		LoadGraphic(bkg3);
		LoadGraphic(boss);
		
		SetLife(2000);
		SetDamageRate(0, 0);
		SetEnemyMarker(true);
		
		SetMovePosition02(GetCenterX, -15, 0);
		
		intro;
    }

    @MainLoop
	{
		SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
		
		if(alpha>2){alpha-=3;}
		frame++;
		yield;
    }

    @DrawLoop
	{
		//Background
		SetGraphicScale(1, 1);
		SetAlpha(255);
		SetTexture(bkg);
		SetColor(255,255,255);
		SetGraphicRect(0, 0, -1024, -1024);
		DrawGraphic(GetCenterX, GetCenterY);
		
		SetTexture(bkg2);
		SetColor(200,200,255);
		SetGraphicRect(0, 0, 512, 512);
		SetAlpha(230);
		DrawGraphic(GetCenterX,GetCenterY);
		
		SetTexture(boss);
		SetAlpha(255);
		SetColor(255,255,255);
		SetGraphicRect(0, 64, 63, 127);
		DrawGraphic(GetX,GetY);
		
		SetTexture(bkg3);
		SetGraphicRect(224, 0, 256, 32);
		SetGraphicScale(100, 100);
		SetAlpha(alpha);
		DrawGraphic(GetCenterX,GetCenterY);
    }

    @Finalize
	{
    }
	
	function Wait(frames){loop(frames){yield;}}
	
	task intro
	{
		PlaySE(GetCurrentScriptDirectory ~ "sfx/se_cat00.wav");
		PlaySE(GetCurrentScriptDirectory ~ "sfx/fall.wav");
		PlayMusic(GetCurrentScriptDirectory ~ "bgm/2.mp3");
		Wait(110);
		waveofdestruction;
		SetMovePosition03(GetCenterX, 350, 8, 20);
		Wait(40);
		SetLife(0);
	}
	
	task waveofdestruction
	{
		loop
		{
			ascent(l in -1..2){CreateShot02(GetX, GetY, 10, 270 + l*360/24, -0.05, 4, 66, 11);}
			ascent(l in -3..4){CreateShot02(GetX, GetY, 10, 270 + l*360/16, -0.05, 4, 52, 11);}
			ascent(l in 0..12){CreateShot02(GetX, GetY, 10, l*360/12 + 15, -0.05, 4, 1, 11);}
			ascent(l in 0..16){CreateShot02(GetX, GetY, 10, l*360/16 + 15, 0.1, 15, 11, 11);}
			ascent(l in 0..16){CreateShot02(GetX, GetY, 10, l*360/16 + 4, 0.1, 15, 10, 11);}
			Wait(2);
		}
	}
}