#e
#Title[dʏEasy]
#Text[]
#Image[.]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
    let name    = "dʏEasy";
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "..\lib/dot_daiyousei.png"; 
    let imgFam  = csd ~ "img\familiar.png";
SetRateScoreSystemEnable(false);
    // ʒu
    let xIni    = GetCenterX;
    let yIni    = GetClipMinY + 128;
	let wIni=60;
let angX=0;
let count=0;
    @Initialize {
        SetTimer(40);
        SetLife(2200);
        SetDamageRate(5, 5);
        LoadGraphic(imgBoss);
        LoadGraphic(imgFam);
        SetTexture(imgBoss);
	InitializeAction();
	SetEnemyMarker(true);
        TMain;
    }

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

    @DrawLoop {
        DrawGraphic(GetX, GetY);
	DrawBoss( imgBoss );
	SetGraphicAngle(angX,0,0);
    }

    @Finalize {
        DeleteGraphic(imgBoss);
	loop(10)
	{
		ItemSet(GetX+rand(-40,40),GetY+rand(-40,40),1);
		ItemSet(GetX+rand(-40,40),GetY+rand(-40,40),2);
	}
    }

    // C^XN
task TMain 
{
	yield;
	drawx;
	standBy;
	Trate;
	TMove;
	shot;
}

task drawx
{
	loop(60)
	{
		yield;
	}
	loop
	{
	if(count>=180 && count<=210)
	{
		angX+=3;
	}
	if(count>=210 && count<=240)
	{
		angX-=3;
	}
	if(count>=300)
	{
		count=0;
	}
	count++;
	yield;
	}
}

task Trate
{
	wait(60);
        SetDamageRate(100, 100);
}

task TMove
{
let dir=rand_int(0,1)*2-1;
	loop
	{
	wait(210);
	SetX(xIni+dir*100);
	wait(300);
	SetX(xIni-dir*100);
	wait(300);
	SetX(xIni);
	wait(90);
	}
}

sub standBy//ʒu
{
	SetAction(ACT_MOVE, 60);
	SetMovePosition02(xIni, yIni, wIni);
	SetInvincibility(wIni);
	wait(wIni);
}


task shot
{
loop
{
	let angle=rand(0,360);
	kunaishot(angle,RED31,1);
	wait(40);
	kunaishot(angle,BLUE31,-1);
	wait(260);
}
}

task kunaishot(let angle,let color,let dir)
{
	ascent(let j in 0..4)
	{
	ascent(let i in 0..12)
	{
	CreateShot01(GetX,GetY,1+0.2*j,angle+i*30+j*2*dir,color,0);
	}
	wait(8);
	}
}


#include_function ".\..\txt\data.txt"
#include_function ".\..\lib/lib_anime_Daiyousei.txt"
}
