#TouhouDanmakufu
#Title[Anti-Boredom Measure "Cruel Game"]
#Text[]
#BackGround[User(".\img\cathedral.png", 0, 0)]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
	let gd = GetCurrentScriptDirectory;
	let bgm = gd~"FinalAnswer.mp3";
	let shot = gd~"lib\supershot.txt";
	let enemy = gd~"img\bern.png";
	let cutin = gd~"img\bern cutin1.png";
	let spell = gd~"img\kakera.png";

	let spella = 0;

	@Initialize
	{
		SetLife(3000);
		SetDamageRate(60, 0);
		SetTimer(70);
		SetMovePosition02(GetCenterX, GetCenterY-120, 90);
		LoadUserShotData(shot);
		SetInvincibility(240);
		CutIn(KOUMA, "Anti-Boredom Measure uCruel Gamev", cutin, 0, 0, 368, 350);
		SetScore(600000);

		mainTask;

		LoadMusic(bgm);
		LoadGraphic(enemy);
		LoadGraphic(spell);
		PlayMusic(bgm);
	}

	@MainLoop
	{
		SetCollisionA(GetX, GetY, 64);
		SetCollisionB(GetX, GetY, 48);

		if(spella<255){spella+=(255/90);}
		if(spella>255){spella=255;}

		yield;
	}

	@DrawLoop
	{
		SetTexture(spell);
		SetGraphicRect(0, 0, 640, 480);
		SetGraphicScale(1, 1);
		SetAlpha(spella);
		DrawGraphic(GetCenterX, GetCenterY);
		
		SetTexture(enemy);
		SetGraphicRect(0, 0, 191, 480);
		SetGraphicScale(0.2, 0.2);
		SetAlpha(255);
		DrawGraphic(GetX, GetY);
	}

	@Background
	{		
	}

	@Finalize
	{
	}

	task mainTask
	{
		loop(120){yield;}
		shoot;
	}

	task shoot
	{
		let ang = 0;
		let shot = 0;
		let dev = 0;

		loop
		{
			loop(36)
			{
				CreateShotA(0, GetX, GetY, 10);
				SetShotDataA(0, 0, 1, 90, 0, 0, 0, 98);
				SetShotDataA(0, 60, 1, 90+shot, 0, 0, 0, 100);
				loop(2)
				{
					CreateShotA(1, 0, 0, 0);
					SetShotDataA(1, 0, 1, ang+dev, 0, 0, 0, 103);
					AddShot(180, 0, 1, 0);
					ang+=21;
				}
				SetShotKillTime(0, 181);
				FireShot(0);
				shot+=6;
				dev+=1;
			}
			loop(60){yield;}
		}
	}
}