#TouhouDanmakufu
#Title[Spellcard 1: History Sign - Swirling Anachronisms]
#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 dir = 0;
		let imgBoss = GetCurrentScriptDirectory ~ "img\AkyuSprite.png";
		let cut = GetCurrentScriptDirectory ~ "img\Cutin.png";
		let bg = GetCurrentScriptDirectory ~ "img\BG.png";
		let lay = GetCurrentScriptDirectory ~ "img\Lay.png";
		

	@Initialize{
		LoadGraphic(imgBoss);
		LoadGraphic(cut);
		LoadGraphic(bg);
		LoadGraphic(lay);
		
		SetLife(5000);
		SetTimer(70);
		SetScore(1000000);
		
		CutIn(YOUMU, "History Sign - Swirling Anachronisms",cut,0,0,500,449);
		
		SetMovePosition01(GetCenterX, GetCenterY, 5);
		wait(160);
		SetMovePosition01(GetCenterX, GetCenterY, 5);
		maintask;
	}

	@MainLoop{
		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;
		sound2;

	}
	task sound2{
		wait(500);
		loop{
			PlaySE(GetCurrentScriptDirectory ~ "se\se_kira00.wav");
			wait(20);
		}
	}
	
	task sound{
		loop{
			PlaySE(GetCurrentScriptDirectory ~ "se\se_tan03.wav");
			wait(20);
		}
	}

	task fire{
		let x = 0;
		let dir = 0;
		let spin = 0;
		let speed =  rand_int(1,3);
		
		loop{
			while(x<4){
				CreateShotA(1,GetEnemyX+50*cos(dir+spin), GetEnemyY+50*sin(dir+spin), 15);
				SetShotDataA(1, 15, 5, dir, 0, -0.5, 0, WHITE23);
				SetShotDataA(1, 75, 1, dir-150, spin/200, 0, 1, RED21);
				SetShotDataA(1, 95, 1, NULL, spin/200, 0, 1, ORANGE21);
				SetShotDataA(1, 115, 1, NULL, spin/200, 0, 1, YELLOW21);
				SetShotDataA(1, 135, 1, NULL, spin/200, 0, 1, GREEN21);
				SetShotDataA(1, 155, 1, NULL, spin/200, 0, 1, AQUA21);
				SetShotDataA(1, 175, 1, NULL, spin/200, 0, 1, BLUE21);
				SetShotDataA(1, 195, 1, NULL, spin/200, 0, 1, PURPLE21);
				SetShotDataA(1, 215, 1, NULL, spin/200, 0, 1, RED21);
				SetShotDataA(1, 235, 1, NULL, spin/200, 0, 1, ORANGE21);
				SetShotDataA(1, 255, 1, NULL, spin/200, 0, 1, YELLOW21);
				SetShotDataA(1, 275, 1, NULL, spin/200, 0, 1, GREEN21);
				SetShotDataA(1, 295, 1, NULL, spin/200, 0, 1, AQUA21);
				SetShotDataA(1, 315, 1, NULL, spin/200, 0, 1, BLUE21);
				SetShotDataA(1, 335, 1, NULL, spin/200, 0, 1, PURPLE21);
				SetShotDataA(1, 375, 1, NULL, spin/200, 0, 1, RED21);
				SetShotDataA(1, 395, 1, NULL, spin/200, 0, 1, ORANGE21);
				SetShotDataA(1, 415, 1, NULL, spin/200, 0, 1, YELLOW21);
				SetShotDataA(1, 435, 1, NULL, spin/200, 0, 1, GREEN21);
				SetShotDataA(1, 455, 1, NULL, spin/200, 0, 1, AQUA21);
				SetShotDataA(1, 475, 1, NULL, spin/200, 0, 1, BLUE21);
				SetShotDataA(1, 495, 1, NULL, spin/200, 0, 1, PURPLE21);
				SetShotDataA(1, 500, 4, NULL, 1, 0, 4, WHITE21);
				FireShot(1);

				CreateShotA(2,GetEnemyX+50*cos(dir-spin), GetEnemyY+50*sin(dir-spin), 15);
				SetShotDataA(2, 105, 5, dir, 0, -0.5, 0, WHITE23);
				SetShotDataA(2, 165, 1, NULL, spin/200, 0, 1, RED21);
				SetShotDataA(2, 185, 1, NULL, spin/200, 0, 1, ORANGE21);
				SetShotDataA(2, 205, 1, NULL, spin/200, 0, 1, YELLOW21);
				SetShotDataA(2, 225, 1, NULL, spin/200, 0, 1, GREEN21);
				SetShotDataA(2, 245, 1, NULL, spin/200, 0, 1, AQUA21);
				SetShotDataA(2, 265, 1, NULL, spin/200, 0, 1, BLUE21);
				SetShotDataA(2, 285, 1, NULL, spin/200, 0, 1, PURPLE21);
				SetShotDataA(2, 305, 1, NULL, spin/200, 0, 1, RED21);
				SetShotDataA(2, 325, 1, NULL, spin/200, 0, 1, ORANGE21);
				SetShotDataA(2, 345, 1, NULL, spin/200, 0, 1, YELLOW21);
				SetShotDataA(2, 365, 1, NULL, spin/200, 0, 1, GREEN21);
				SetShotDataA(2, 385, 1, NULL, spin/200, 0, 1, AQUA21);
				SetShotDataA(2, 405, 1, NULL, spin/200, 0, 1, BLUE21);
				SetShotDataA(2, 425, 1, NULL, spin/200, 0, 1, PURPLE21);
				SetShotDataA(2, 445, 1, NULL, spin/200, 0, 1, RED21);
				SetShotDataA(2, 465, 1, NULL, spin/200, 0, 1, ORANGE21);
				SetShotDataA(2, 485, 1, NULL, spin/200, 0, 1, YELLOW21);
				SetShotDataA(2, 500, 4, NULL, 1, 0, 4, WHITE21);
				FireShot(2);

				dir+=360/4;
				x++;
				spin++;
				speed++;
			}
			x = 0;
			if(speed == 10){
				speed = rand_int(1,3);
				yield;
			}
			if(spin == 359){
				spin = 0;
				yield;
			}
			dir = 0;
			wait(10);
			yield;
		}
	}

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

}

	