#TouhouDanmakufu[Single]
#Title[Fourth Non-Spellcard]
#Text[Fourth 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 cut = CSD ~ "img\Koakuma Cut.png";
    let bgSpell = CSD ~ "img\BGspell.png";
    let shot = GetCurrentScriptDirectory ~ ".\sounds\se_tan00.wav";
    let charge = GetCurrentScriptDirectory ~ ".\sounds\Shot1.wav";
    

  @Initialize {
        SetLife(4000);
	SetTimer(60);
        SetMovePosition01(GetX,200,5);
	mainTask;
	LoadGraphic(imgBoss);
	LoadGraphic(bgSpell);
	LoadGraphic(cut);
	LoadSE(shot);
	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{ 

	SetTexture(bgSpell);
	SetRenderState(ALPHA);
	SetAlpha(255);
	SetGraphicRect(0,0,512,512);
	SetGraphicScale(1,1);
	SetGraphicAngle(0,0,0);
	DrawGraphic(GetCenterX,GetCenterY);   
    }

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

	task movement{
		loop{
			SetMovePosition01(GetCenterX-50,200,1);
			wait(240);
			SetMovePosition01(GetCenterX+50,200,1);
			wait(240);
			SetMovePosition01(GetCenterX+50,100,1);
			wait(240);
			SetMovePosition01(GetCenterX-50,100,1);
			wait(240);
			yield;
		}
}

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

			PlaySE(charge);
			CreateShotA(1,GetEnemyX+20*cos(dir),GetEnemyY-20*sin(dir),1);
			SetShotDataA(1,0,0,dir,0,0,0,RED05);
			SetShotDataA(1,1,3,dir,-9,0,0,AQUA31);

			CreateShotA(1,GetEnemyX+20*cos(dir),GetEnemyY-20*sin(dir),1);
			SetShotDataA(1,0,0,dir,0,0,0,RED05);
			SetShotDataA(1,50,3,dir,0.0,0,0,AQUA31);
	
			CreateShotA(2,GetEnemyX-20*cos(dir),GetEnemyY+20*sin(dir),1);
			SetShotDataA(2,0,0,dir,0,0,0,PURPLE05);
			SetShotDataA(2,1,3,dir,9,0,0,RED31);

			CreateShotA(2,GetEnemyX-20*cos(dir),GetEnemyY+20*sin(dir),1);
			SetShotDataA(2,0,0,dir,0,0,0,PURPLE05);
			SetShotDataA(2,50,3,dir,0.0,0,0,RED31);
			
			CreateShotA(3,GetEnemyX+100*cos(dir),GetEnemyY+100*sin(dir),1);
			SetShotDataA(3,0,0,dir,0,0,0,PURPLE01);
			SetShotDataA(3,50,2,dir,0.3,0,0,BLUE01);

			CreateShotA(3,GetEnemyX+10*cos(dir),GetEnemyY+10*sin(dir),1);
			SetShotDataA(3,0,0,dir,0,0,0,PURPLE01);
			SetShotDataA(3,1,2,dir,5,0,0,BLUE01);

			CreateShotA(4,GetEnemyX-10*cos(dir),GetEnemyY-10*sin(dir),1);
			SetShotDataA(4,0,0,dir,0,0,0,PURPLE01);
			SetShotDataA(4,1,2,dir,-0.3,0,0,PURPLE01);
			
			CreateShotA(4,GetEnemyX-10*cos(dir),GetEnemyY-10*sin(dir),1);
			SetShotDataA(4,0,0,dir,0,0,0,PURPLE01);
			SetShotDataA(4,1,2,dir,-5,0,0,PURPLE01);

			FireShot(1);
			FireShot(2);
			FireShot(3);
			FireShot(4);
			dir+=360/10;
			x++;
			
		}


		x = 0;
		dir = 0;
		wait(30);

			yield;

		}
}

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



	
}