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/enem1bg1.png";
	let bkg2 = GetCurrentScriptDirectory ~ "c6/c6shots.png";
	let boss = GetCurrentScriptDirectory ~ "c6/enem1.png";
	
    @Initialize
	{
		LoadUserShotData(GetCurrentScriptDirectory ~ "c6/c6shots.txt");
		LoadGraphic(bkg);
		LoadGraphic(bkg2);
		LoadGraphic(boss);
		
		SetLife(2000);
		SetTimer(22);
		SetScore(1);
		SetDamageRate(0, 0);
		MagicCircle(false);
		SetEnemyMarker(false);
		
		SetMovePosition03(GetCenterX, GetCenterY - 120, 15, 5);
		
		intro;
    }

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

    @DrawLoop
	{
		//Background
		SetAlpha(255);
		SetTexture(bkg);
		SetGraphicRect(0, 0, 1024, 1024);
		SetColor(255, 100, 100);
		SetGraphicScale(0.5, 0.5);
		DrawGraphic(GetCenterX, GetCenterY);
		
		SetTexture(bkg);
		SetGraphicScale(1, 1);
		SetColor(255, 255, 255);
		SetGraphicRect(0, 0, 512, 512+frame);
		SetAlpha(50);
		DrawGraphic(GetCenterX,GetCenterY);
		
		SetTexture(boss);
		SetAlpha(150);
		if(GetSpeedX<-0.2 && GetSpeedX>=-1){
			SetGraphicRect(192, 64, 256, 128);
			SetGraphicAngle(180, 0, 0);
		}
		else if(GetSpeedX<-1){
			SetGraphicRect(64, 64, 128, 128);
			SetGraphicAngle(180, 0, 0);
		}
		else if(GetSpeedX>0.2 && GetSpeedX<=1){
			SetGraphicRect(192, 64, 256, 128);
			SetGraphicAngle(0, 0, 0);
		}
		else if(GetSpeedX>1){
			SetGraphicRect(64, 64, 128, 128);
			SetGraphicAngle(0, 0, 0);
		}
		else{SetGraphicRect(floor(frame/8)*64,0,63+floor(frame/8)*64,63);}
		DrawGraphic(GetX,GetY+5*cos(frame*2));
		
		SetTexture(bkg2);
		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");
		Wait(70);
		loop
		{
			SetMovePositionRandom01(rand(-80,80),rand(30,60), 3, 140,100, 300,GetCenterY-100);
			loop(20)
			{
				CreateShot12(GetX, GetY, 2+rand(0,2), -1+rand(0,2), -0.03-rand(0,0.05), 0.05-rand(0,0.05), -2-rand(0,2), 3, 19, 0);
				CreateShot12(GetX, GetY, -2-rand(0,2), -1+rand(0,2), 0.03+rand(0,0.05), 0.05-rand(0,0.05), 2+rand(0,2), 3, 19, 0);
				CreateShot12(GetX, GetY, 2+rand(0,2), -1+rand(0,2), -0.03-rand(0,0.05), 0.05-rand(0,0.05), -2-rand(0,2), 3, 20, 0);
				CreateShot12(GetX, GetY, -2-rand(0,2), -1+rand(0,2), 0.03+rand(0,0.05), 0.05-rand(0,0.05), 2+rand(0,2), 3, 20, 0);
				PlaySE(GetCurrentScriptDirectory ~ "sfx/se_kira00.wav");
				Wait(1);
			}
			
			Wait(89);
		}
	}
}