script_enemy_main{

let side=GetArgument[0];
let distance=0;
let wavesize=0;
let waveangle=0;
let speed=3;

let frame=0;
let time=0;
let miny=GetClipMinY; let maxy=GetClipMaxY; let minx=GetClipMinX; let maxx=GetClipMaxX;
let cx=GetCenterX; let cy=GetCenterY;

let SEshot1=("script\SoundEffects\shotm4.wav");

let GRfamiliar=("\script\Images\OtherEffects\SpellCircle1b.png");

@Initialize{
	LoadSE("script\SoundEffects\shotm4.wav");
	LoadGraphic("\script\Images\OtherEffects\SpellCircle1b.png");

	SetScore(1);
	SetLife(1);
}
	
@MainLoop{

if(side==1){ SetX((cx+distance)+wavesize*cos(waveangle)); }
if(side==2){ SetX((cx-distance)-wavesize*cos(waveangle)); }

if(distance<GetArgument[1]){ distance+=GetArgument[1]/30; }
if(speed<8 && time>=30){ speed+=5/60; }


if(GetCommonData("Difficulty")==1){
	if(time%2==0 && time>=30){
		if(side==1){
		CreateShot01(GetX,GetY,speed,90-10+15*cos(time+90),12,10);
		CreateShot01(GetX,GetY,speed,270-10+15*cos(time+90),12,10);
		CreateShot01(GetX,GetY,speed,0+15-60*cos(time+90),11,10);
		CreateShot01(GetX,GetY,speed,180+15+40*cos(time-190),11,10);
		}
		if(side==2){
		CreateShot01(GetX,GetY,speed,90+10-15*cos(time+90),12,10);
		CreateShot01(GetX,GetY,speed,270+10-15*cos(time+90),12,10);
		CreateShot01(GetX,GetY,speed,180-15+60*cos(time+90),11,10);
		CreateShot01(GetX,GetY,speed,0-15-40*cos(time-190),11,10);
		}
	}
	if(time%4==0 && time>=30){ PlaySE(SEshot1); }
} //Easy

//================================================================================================

if(GetCommonData("Difficulty")==2){
	if(time%2==0 && time>=30){
		if(side==1){
		CreateShot01(GetX,GetY,speed,90-20+25*cos(time-180),12,0);
		CreateShot01(GetX,GetY,speed,270-20+25*cos(time-180),12,0);
		CreateShot01(GetX,GetY,speed,90-45+45*cos(time+0),11,0);
		CreateShot01(GetX,GetY,speed,270-45+45*cos(time+0),11,0);
		}
		if(side==2){
		CreateShot01(GetX,GetY,speed,90+20-25*cos(time-180),12,0);
		CreateShot01(GetX,GetY,speed,270+20-25*cos(time-180),12,0);
		CreateShot01(GetX,GetY,speed,90+45-45*cos(time+0),11,0);
		CreateShot01(GetX,GetY,speed,270+45-45*cos(time+0),11,0);
		}
	}
	if(time%4==0 && time>=30){ PlaySE(SEshot1); }
} //Normal

//================================================================================================

if(GetCommonData("Difficulty")==3){
	if(time%2==0 && time>=30){
		if(side==1){
		CreateShot01(GetX,GetY,speed,90+25*cos(time+90),12,10);
		CreateShot01(GetX,GetY,speed,270+25*cos(time+90),12,10);
		CreateShot01(GetX,GetY,speed,0+15-50*cos(time+180),11,10);
		CreateShot01(GetX,GetY,speed,180+15+50*cos(time-180),11,10);
		}
		if(side==2){
		CreateShot01(GetX,GetY,speed,90-25*cos(time+90),12,10);
		CreateShot01(GetX,GetY,speed,270-25*cos(time+90),12,10);
		CreateShot01(GetX,GetY,speed,180-15+50*cos(time+180),11,10);
		CreateShot01(GetX,GetY,speed,0-15-50*cos(time-180),11,10);
		}
	}
	if(time%4==0 && time>=30){ PlaySE(SEshot1); }
} //Hard

//================================================================================================

if(GetCommonData("Difficulty")==4){
	if(time%2==0 && time>=30){
		if(side==1){
		CreateShot01(GetX,GetY,speed,90+10+30*cos(time+90),12,10);
		CreateShot01(GetX,GetY,speed,270+10+30*cos(time+90),12,10);
		CreateShot01(GetX,GetY,speed,0+20-60*cos(time+190),11,10);
		CreateShot01(GetX,GetY,speed,180+20+60*cos(time-190),11,10);
		}
		if(side==2){
		CreateShot01(GetX,GetY,speed,90-10-30*cos(time+90),12,10);
		CreateShot01(GetX,GetY,speed,270-10-30*cos(time+90),12,10);
		CreateShot01(GetX,GetY,speed,180-20+60*cos(time+190),11,10);
		CreateShot01(GetX,GetY,speed,0-20-60*cos(time-190),11,10);
		}
	}
	if(time%4==0 && time>=30){ PlaySE(SEshot1); }
} //Lunatic



time++;
frame++;

}

@DrawLoop{
	SetTexture(GRfamiliar);
	SetGraphicRect(0,0,200,200);
	SetGraphicScale(0.2,0.2);
	SetColor(150,150,150);
	SetRenderState(ADD);
	SetAlpha(255);
	SetGraphicAngle(0,0,time*2);
	DrawGraphic(GetX,GetY);
}

@Finalize{
}

}