#TouhouDanmakufu[Single]
#Title[Sixth Non-Spellcard]
#Text[Sixth Non-Spellcard]
#BGM[.\Feast.mp3]
#PlayLevel[Normal]
#Player[FREE]
#ScriptVersion[2]


script_enemy_main{
    
    let frame = 0;
    let CSD = GetCurrentScriptDirectory;
    let imgBoss = CSD ~ "img\Koakuma.png";	
    let shot = GetCurrentScriptDirectory ~ ".\sounds\se_tan00.wav";
    let lazer = GetCurrentScriptDirectory ~ ".\sounds\se_lazer01.wav";
    let charge = GetCurrentScriptDirectory ~ ".\sounds\se_ch02.wav";

  @Initialize {
        SetLife(4000);
	SetTimer(60);
        SetMovePosition01(GetX,120,1);
	mainTask;
	LoadGraphic(imgBoss);
	LoadSE(shot);
	LoadSE(lazer);
	LoadSE(charge);
    }

    @MainLoop {
        
	SetCollisionA(GetX,GetY,32);
	SetCollisionB(GetX,GetY,32);
	yield;
}
	 
    @DrawLoop { 

	SetTexture(imgBoss);
	SetRenderState(ALPHA);
	SetAlpha(255);
	SetGraphicScale(1,1);
	SetGraphicAngle(0,0,0);
	SetGraphicRect(0,0,132,132);
	DrawGraphic(GetX,GetY);   
	
	}

    @BackGround{ 

    }

    @Finalize {
	DeleteGraphic(imgBoss);
	DeleteSE(lazer);
	DeleteSE(shot);
	DeleteSE(charge);
    }
	
	task mainTask{
		wait(120);
		yield;
		fire;
		movement;
    }

	task movement{
		loop{
			SetMovePosition01(GetCenterX-60,200,1);
			wait(240);
			PlaySE(charge);
			SetMovePosition01(GetCenterX+60,200,1);
			wait(240);
			yield;
		}
}

	task fire{
		let x = 0;
		let dir = 0;
		loop{
			while(x<36){

			PlaySE(shot);
			
			CreateShotA(1,GetEnemyX+20*cos(dir),GetEnemyY-20*sin(dir),10);
			SetShotDataA(1,0,0,dir,0,0,0,RED05);
			SetShotDataA(1,1,2,dir,-0.2,0,1,BLUE21);
			
			CreateShotA(1,GetEnemyX+400*cos(dir),GetEnemyY-900*sin(dir),10);
			SetShotDataA(1,0,0,dir,0,0,0,RED05);
			SetShotDataA(1,1,2,dir,0.2,0,2,BLUE21);
	
			CreateShotA(2,GetEnemyX-10*cos(dir),GetEnemyY+10*sin(dir),10);
			SetShotDataA(2,0,0,dir,0,0,0,PURPLE05);
			SetShotDataA(2,1,2,dir,0.2,0,0,RED21);

			CreateShotA(2,GetEnemyX-100*cos(dir),GetEnemyY+700*sin(dir),10);
			SetShotDataA(2,0,0,dir,0,0,0,PURPLE05);
			SetShotDataA(2,1,2,dir,-0.2,0,0,RED21);

			CreateShotA(3,GetEnemyX-10*cos(dir),GetEnemyY+10*sin(dir),10);
			SetShotDataA(3,0,0,dir,0,0,0,PURPLE05);
			SetShotDataA(3,1,1,dir,-0.0,0,0,YELLOW31);
			
			CreateShotA(3,GetEnemyX-10*cos(dir),GetEnemyY+10*sin(dir),10);
			SetShotDataA(3,0,0,dir,0,0,0,PURPLE05);
			SetShotDataA(3,1,1,dir,-0.0,0,0,YELLOW31);

			FireShot(1);
			FireShot(2);
			FireShot(3);
			dir+=360/26;

			x++;
		}


		x = 0;
		dir = 0;
		wait(20);
			
			PlaySE(lazer);
			CreateLaser01(GetEnemyX,GetEnemyY,5,40,100,10,GREEN01,1);
			wait(20);
			CreateLaser01(GetEnemyX,GetEnemyY,5,130,100,10,GREEN01,1);
			wait(20);
			yield;

		}
}

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



	
}