script_enemy_main{

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

let warning=0;
let warningfade=0;

let SEalert1=("script\SoundEffects\alert1.wav");
let GRwarning=("script\Images\OtherEffects\Warning.png");

@Initialize{
	SetLife(1);
	LoadSE("script\SoundEffects\alert1.wav");
	LoadGraphic("script\Images\OtherEffects\Warning.png");
}
	
@MainLoop{

if(time==0){
	warning=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(warning,cx+256,cy);
	ObjEffect_SetLayer(warning,7); ObjEffect_SetTexture(warning,GRwarning); ObjEffect_SetRenderState(warning,ADD);
	ObjEffect_SetPrimitiveType(warning,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(warning,4);
	ObjEffect_SetVertexXY(warning,0,-450,-150); ObjEffect_SetVertexUV(warning,0,0,0);
	ObjEffect_SetVertexXY(warning,1,450,-150); ObjEffect_SetVertexUV(warning,1,900,0);
	ObjEffect_SetVertexXY(warning,2,-450,150); ObjEffect_SetVertexUV(warning,2,0,300);
	ObjEffect_SetVertexXY(warning,3,450,150); ObjEffect_SetVertexUV(warning,3,900,300);
	ObjEffect_SetVertexColor(warning,0,255,255,255,255); ObjEffect_SetVertexColor(warning,1,255,255,255,255);
	ObjEffect_SetVertexColor(warning,2,255,255,255,255); ObjEffect_SetVertexColor(warning,3,255,255,255,255);
}

if((time-20)%40==0 && time<180){ PlaySE(SEalert1); }
if(time<60){ warningfade+=220/60; }
if(time>150 && warningfade>0){ warningfade-=220/60; }
		ObjEffect_SetVertexColor(warning,0,warningfade,warningfade,warningfade,warningfade); ObjEffect_SetVertexColor(warning,1,warningfade,warningfade,warningfade,warningfade);
		ObjEffect_SetVertexColor(warning,2,warningfade,warningfade,warningfade,warningfade); ObjEffect_SetVertexColor(warning,3,warningfade,warningfade,warningfade,warningfade);	
		Obj_SetPosition(warning,cx+256-(time*2),cy);
if(time>=150 && warningfade<=0){ Obj_Delete(warning); VanishEnemy; }

time++;
frame++;

}
}