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 type=1;
if(GetArgument==1){ type=2; }
let ani=0;
let explosion=0;
let GRexplosion1=("\script\Images\OtherEffects\ExplosionAlpha.png");
let GRexplosion2=("\script\Images\OtherEffects\ExplosionAdd.png");

@Initialize{
	LoadGraphic("\script\Images\OtherEffects\ExplosionAlpha.png");
	LoadGraphic("\script\Images\OtherEffects\ExplosionAdd.png");

	SetLife(1);
}

@MainLoop{

if(time==0){
let xsize=69;
let ysize=69;
	explosion=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(explosion,GetX,GetY);
	ObjEffect_SetAngle(explosion,0,0,rand(0,360)); ObjEffect_SetScale(explosion,1,1); ObjEffect_SetLayer(explosion,5);
	if(type==1){ObjEffect_SetTexture(explosion,GRexplosion); ObjEffect_SetRenderState(explosion,ALPHA); }
	if(type==2){ObjEffect_SetTexture(explosion,GRexplosion); ObjEffect_SetRenderState(explosion,ADD); }
	ObjEffect_SetPrimitiveType(explosion,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(explosion,4);
	ObjEffect_SetVertexXY(explosion,0,-(xsize/2),-(ysize/2)); ObjEffect_SetVertexUV(explosion,0,0,0);
	ObjEffect_SetVertexXY(explosion,1,xsize/2,-(ysize/2)); ObjEffect_SetVertexUV(explosion,1,xsize,0);
	ObjEffect_SetVertexXY(explosion,2,-(xsize/2),ysize/2); ObjEffect_SetVertexUV(explosion,2,0,ysize);
	ObjEffect_SetVertexXY(explosion,3,xsize/2,ysize/2); ObjEffect_SetVertexUV(explosion,3,xsize,ysize);
	ObjEffect_SetVertexColor(explosion,0,200,255,255,255); ObjEffect_SetVertexColor(explosion,1,200,255,255,255);
	ObjEffect_SetVertexColor(explosion,2,200,255,255,255); ObjEffect_SetVertexColor(explosion,3,200,255,255,255);
}

let xsize=69;
let ysize=69;
ObjEffect_SetVertexUV(explosion,0,ani,0); ObjEffect_SetVertexUV(explosion,1,ani+xsize,0);
ObjEffect_SetVertexUV(explosion,2,ani,ysize); ObjEffect_SetVertexUV(explosion,3,ani+xsize,ysize);
	if(time%4==0 && ani<490){ ani+=70; }
	if(ani>=490){ Obj_Delete(explosion); VanishEnemy; }

time++;
}

}