script_enemy_main{

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

let effect1=0;
let effect2=0;
let effect3=0;
let scale1=0;
let scale2=0;
let fade=255;

let fadeblack=0;
let fadecolor=0;
let EFblack=("\script\Images\OtherEffects\Wall.png");
let cx2=320;
let cy2=240;

let EFstageclear=("\script\Images\OtherEffects\StageClear1.png");
let EFwhite=("\script\Images\OtherEffects\StageClear2.png");

@Initialize{
	LoadGraphic("\script\Images\OtherEffects\StageClear1.png");
	LoadGraphic("\script\Images\OtherEffects\StageClear2.png");

	LoadGraphic("\script\Images\OtherEffects\Wall.png");

	SetLife(100);
	SetScore(100);

	SetCommonData("PlayMusic",99);
}

@MainLoop{

if(time==0){
let xsize=400;
let ysize=100;
	effect1=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(effect1,cx,cy);
	ObjEffect_SetScale(effect1,1,scale1);
	ObjEffect_SetLayer(effect1,7); ObjEffect_SetTexture(effect1,EFstageclear); ObjEffect_SetRenderState(effect1,ALPHA);
	ObjEffect_SetPrimitiveType(effect1,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(effect1,4);
	ObjEffect_SetVertexXY(effect1,0,-(xsize/2),-(ysize/2)); ObjEffect_SetVertexUV(effect1,0,0,0);
	ObjEffect_SetVertexXY(effect1,1,xsize/2,-(ysize/2)); ObjEffect_SetVertexUV(effect1,1,xsize,0);
	ObjEffect_SetVertexXY(effect1,2,-(xsize/2),ysize/2); ObjEffect_SetVertexUV(effect1,2,0,ysize);
	ObjEffect_SetVertexXY(effect1,3,xsize/2,ysize/2); ObjEffect_SetVertexUV(effect1,3,xsize,ysize);
	ObjEffect_SetVertexColor(effect1,0,fade,255,255,255); ObjEffect_SetVertexColor(effect1,1,fade,255,255,255);
	ObjEffect_SetVertexColor(effect1,2,fade,255,255,255); ObjEffect_SetVertexColor(effect1,3,fade,255,255,255);
}
if(time==40){
let xsize=400;
let ysize=98;
	effect2=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(effect2,cx,cy+25);
	ObjEffect_SetScale(effect2,1,scale2);
	ObjEffect_SetLayer(effect2,6); ObjEffect_SetTexture(effect2,EFwhite); ObjEffect_SetRenderState(effect2,ALPHA);
	ObjEffect_SetPrimitiveType(effect2,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(effect2,4);
	ObjEffect_SetVertexXY(effect2,0,-(xsize/2),-(ysize/2)); ObjEffect_SetVertexUV(effect2,0,0,0);
	ObjEffect_SetVertexXY(effect2,1,xsize/2,-(ysize/2)); ObjEffect_SetVertexUV(effect2,1,xsize,0);
	ObjEffect_SetVertexXY(effect2,2,-(xsize/2),ysize/2); ObjEffect_SetVertexUV(effect2,2,0,ysize);
	ObjEffect_SetVertexXY(effect2,3,xsize/2,ysize/2); ObjEffect_SetVertexUV(effect2,3,xsize,ysize);
	ObjEffect_SetVertexColor(effect2,0,255,255,255,255); ObjEffect_SetVertexColor(effect2,1,255,255,255,255);
	ObjEffect_SetVertexColor(effect2,2,255,255,255,255); ObjEffect_SetVertexColor(effect2,3,255,255,255,255);

	effect3=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(effect3,cx,cy-25);
	ObjEffect_SetScale(effect3,1,scale2);
	ObjEffect_SetLayer(effect3,6); ObjEffect_SetTexture(effect3,EFwhite); ObjEffect_SetRenderState(effect3,ALPHA);
	ObjEffect_SetPrimitiveType(effect3,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(effect3,4);
	ObjEffect_SetVertexXY(effect3,0,-(xsize/2),-(ysize/2)); ObjEffect_SetVertexUV(effect3,0,0,0);
	ObjEffect_SetVertexXY(effect3,1,xsize/2,-(ysize/2)); ObjEffect_SetVertexUV(effect3,1,xsize,0);
	ObjEffect_SetVertexXY(effect3,2,-(xsize/2),ysize/2); ObjEffect_SetVertexUV(effect3,2,0,ysize);
	ObjEffect_SetVertexXY(effect3,3,xsize/2,ysize/2); ObjEffect_SetVertexUV(effect3,3,xsize,ysize);
	ObjEffect_SetVertexColor(effect3,0,255,255,255,255); ObjEffect_SetVertexColor(effect3,1,255,255,255,255);
	ObjEffect_SetVertexColor(effect3,2,255,255,255,255); ObjEffect_SetVertexColor(effect3,3,255,255,255,255);
}

ObjEffect_SetVertexColor(effect1,0,fade,255,255,255); ObjEffect_SetVertexColor(effect1,1,fade,255,255,255);
ObjEffect_SetVertexColor(effect1,2,fade,255,255,255); ObjEffect_SetVertexColor(effect1,3,fade,255,255,255);

ObjEffect_SetScale(effect1,1,scale1);


ObjEffect_SetVertexColor(effect2,0,fade,255,255,255); ObjEffect_SetVertexColor(effect2,1,fade,255,255,255);
ObjEffect_SetVertexColor(effect2,2,fade,255,255,255); ObjEffect_SetVertexColor(effect2,3,fade,255,255,255);
ObjEffect_SetVertexColor(effect3,0,fade,255,255,255); ObjEffect_SetVertexColor(effect3,1,fade,255,255,255);
ObjEffect_SetVertexColor(effect3,2,fade,255,255,255); ObjEffect_SetVertexColor(effect3,3,fade,255,255,255);

ObjEffect_SetVertexXY(effect2,0,-200,0); ObjEffect_SetVertexXY(effect2,1,200,0);
ObjEffect_SetVertexXY(effect2,2,-200,scale2); ObjEffect_SetVertexXY(effect2,3,200,scale2);
ObjEffect_SetVertexXY(effect3,0,-200,0); ObjEffect_SetVertexXY(effect3,1,200,0);
ObjEffect_SetVertexXY(effect3,2,-200,-scale2); ObjEffect_SetVertexXY(effect3,3,200,-scale2);

ObjEffect_SetScale(effect2,1,1); ObjEffect_SetScale(effect3,1,1);


if(time>=40 && scale2<120){ scale2+=1+1*cos(scale2); }
if(scale1<1){ scale1+=1*sin(time); }
if(time>=150){ fade-=255/60; }


if(time==150){
	fadeblack=(Obj_Create(OBJ_EFFECT)); Obj_SetPosition(fadeblack,cx2,cy2); ObjEffect_SetLayer(fadeblack,1); ObjEffect_SetTexture(fadeblack,EFblack);
	ObjEffect_SetPrimitiveType(fadeblack,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(fadeblack,4); ObjEffect_SetRenderState(fadeblack,ALPHA);
	ObjEffect_SetVertexXY(fadeblack,0,-320,-240); ObjEffect_SetVertexUV(fadeblack,0,0,0);
	ObjEffect_SetVertexXY(fadeblack,1,320,-240); ObjEffect_SetVertexUV(fadeblack,1,640,0);
	ObjEffect_SetVertexXY(fadeblack,2,-320,240); ObjEffect_SetVertexUV(fadeblack,2,0,480);
	ObjEffect_SetVertexXY(fadeblack,3,320,240); ObjEffect_SetVertexUV(fadeblack,3,640,480);
}

ObjEffect_SetVertexColor(fadeblack,0,fadecolor,0,0,0); ObjEffect_SetVertexColor(fadeblack,1,fadecolor,0,0,0);
ObjEffect_SetVertexColor(fadeblack,2,fadecolor,0,0,0); ObjEffect_SetVertexColor(fadeblack,3,fadecolor,0,0,0);

if(fadecolor<255 && time>=150){ fadecolor+=5; }


if(fadecolor==255){
	if(GetCommonDataDefault("InStagePractise",0)>0){ SetCommonData("InStagePractise",3); }
	Obj_Delete(effect1);
	Obj_Delete(effect2);
	Obj_Delete(effect3);
	SetCommonData("NextStage",GetCommonData("Stage")+1);
	VanishEnemy;
}

time++;
}

}