#TouhouDanmakufu
#Title[Spellcard 4: Issun-Boshi's Tale - Oni's Magic]
#Text[...]
#BackGround[User(.\img\Background.png,1,1)]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main{
	let f = 0; 
	let f2 = 0;
	let f3 = 0;
	let f4 = 0;
	let slide = 0;
	let cut = GetCurrentScriptDirectory ~ "img\Cutin.png";
		let bg = GetCurrentScriptDirectory ~ "img\BG.png";
		let lay = GetCurrentScriptDirectory ~ "img\Lay.png";
		let imgBoss = GetCurrentScriptDirectory ~ "img\AkyuSprite.png";

		let dir = 0;

	@Initialize{
		LoadGraphic(cut);
		LoadGraphic(bg);
		LoadGraphic(lay);
	LoadGraphic(imgBoss);
		SetLife(5000);
		SetTimer(40);
		SetScore(1000000);
		
		CutIn(YOUMU, "Issun-Boshi's Tale - Oni's Magic",cut,0,0,500,449);
		maintask;
	}

	@MainLoop{
		SetMovePosition01(GetCenterX, GetCenterY-150, 5);
		SetCollisionA(GetX, GetY, 32);
		SetCollisionB(GetX, GetY, 16);
		yield;
	}

	@DrawLoop{
	SetTexture(imgBoss);
	SetGraphicScale(1,1);
	if(f>=0 && f<5){SetGraphicRect(28,29,100,99);}
	if(f>=5 && f<10){SetGraphicRect(28,155,100,229);}
	if(f>=10 && f<20){SetGraphicRect(28,281,100,359);}
	f2 = 0;
	f++;
	if(f==20){
	f=0;
	f3 = 0;
	f4 = 0;
	}
	DrawGraphic(GetX,GetY);


	}

	@BackGround{
	SetTexture(bg);
		SetRenderState(ALPHA);
		SetAlpha(255);
		SetGraphicRect(0,0,774,1032);
		SetGraphicScale(0.5,0.5);
		SetGraphicAngle(0,0,0);
		DrawGraphic(GetCenterX,GetCenterY);
		
		SetTexture(lay);
		SetRenderState(ALPHA);
		SetAlpha(255);
		SetGraphicRect(0,0,10000+slide,10000+slide);
		SetGraphicScale(0.25,0.25);
		SetGraphicAngle(0,0,0);
		DrawGraphic(GetCenterX,GetCenterY);
	
		slide+=8;
	}

	@Finalize{
	DeleteGraphic(cut);
	DeleteGraphic(bg);

	}

	task maintask{
		wait(90);
		yield;
		fire;
		sound;

	}
	
	task sound{
		wait(460);
		loop{
				PlaySE(GetCurrentScriptDirectory ~ "se\se_kira00.wav");
				wait(12);
		}
	}

	task fire{
		let x = 0;
		let dir = 0;
		let spin = 0;
		
		loop{
			while(x<4){
				PlaySE(GetCurrentScriptDirectory ~ "se\se_kira02.wav");
				CreateShotA(1,GetCenterX+50*cos(dir), (GetCenterY-200)+50*sin(dir), 0);
				SetShotDataA(1, 0, 5, (spin/2)+90, -spin/13, 0.5, 10, WHITE21);
				SetShotDataA(1, 450, 0.005, NULL, 0, 0.055, 50, RED01);
				SetShotDataA(1, 470, NULL, NULL, 0, 0.055, 50, ORANGE01);
				SetShotDataA(1, 490, NULL, NULL, 0, 0.055, 50, YELLOW01);
				SetShotDataA(1, 510, NULL, NULL, 0, 0.055, 50, GREEN01);
				SetShotDataA(1, 530, NULL, NULL, 0, 0.055, 50, AQUA01);
				SetShotDataA(1, 550, NULL, NULL, 0, 0.055, 50, BLUE01);
				SetShotDataA(1, 570, NULL, NULL, 0, 0.055, 50, PURPLE01);
				SetShotDataA(1, 590, NULL, NULL, 0, 0.055, 50, WHITE01);
				FireShot(1);

				CreateShotA(2,GetCenterX-50*cos(dir), (GetCenterY-200)-50*sin(dir), 0);
				SetShotDataA(2, 0, 5, (-spin/2)+90, spin/13, 0.5, 10, WHITE21);
				SetShotDataA(2, 450, 0.005, NULL, 0, 0.055, 50, RED01);
				SetShotDataA(2, 470, NULL, NULL, 0, 0.055, 50, ORANGE01);
				SetShotDataA(2, 490, NULL, NULL, 0, 0.055, 50, YELLOW01);
				SetShotDataA(2, 510, NULL, NULL, 0, 0.055, 50, GREEN01);
				SetShotDataA(2, 530, NULL, NULL, 0, 0.055, 50, AQUA01);
				SetShotDataA(2, 550, NULL, NULL, 0, 0.055, 50, BLUE01);
				SetShotDataA(2, 570, NULL, NULL, 0, 0.055, 50, PURPLE01);
				SetShotDataA(2, 590, NULL, NULL, 0, 0.055, 50, WHITE01);
				FireShot(2);


				dir+=360/2;
				spin++;
				x++;
			}
			x = 0;
			dir = 0;
			if(spin == 359){
				spin = 0;
				yield;
			}
			wait(1);
			yield;
		}
	}

	function wait(w){
		loop(w){yield;}
	}

}

	