script_enemy_main {
	#include_function "lib\SHOT_REPLACE\shot_replace.dnh"
	let ImgPup1 = "script\img\enemysprites.png";
	let frame = 0;
	let spherev = 1;
	let delay = 180;
	let drawframe = 0;
	@Initialize{
		SetLife(100);
		SetInvincibility(120);
		SetScore(1000);
		LoadGraphic(ImgPup1);
		SetTexture(ImgPup1);
        		SetGraphicRect(0, 0, 64, 64);
		shotinit;
	}
	@MainLoop{
		SetCollisionA(GetX, GetY, 16);
		SetCollisionB(GetX, GetY, 8);
		yield;
		if(GetSpeed > 0) {
			SetSpeed(GetSpeed - 0.025);
		}
		else {
			if(frame == 1) {
				CreateShotA(0, GetX, GetY, 0);
				SetShotDataA(0, 0, 3, GetAngleToPlayer, 0, -0.075, 0, ORANGE05);
				ascent(a in 0..20) {
					CreateShotA(1, 0, 0, 0);
					SetShotDataA(1, 0, 3, a * 18, 0, -0.025, 2, ORANGE02);
					AddShot(60, 0, 1, 0);
					CreateShotA(1, 0, 0, 0);
					SetShotDataA(1, 0, 2, a * 18, 0, -0.025, 2, WHITE02);
					AddShot(60, 0, 1, 0);
				}
				SetShotKillTime(0, 61);
				FireShot(0);
			}
			if(frame == 240) {
				SetMovePosition03(GetX, -1, 11, 2);
			}
			if((GetY < GetClipMinY || GetX > GetClipMaxX) && frame > 180) {
				VanishEnemy;
			}
			else {
				SetSpeed(GetSpeed + 0.025);
			}
			frame++;
		}
		drawframe++;
	}
	@DrawLoop{
		let dx = 0;
		let dy = 96;
		if(drawframe%16 > 4) {
			dx += 32;
		}
		if(drawframe%16 > 8) {
			dx += 32;
		}
		if(drawframe%16 > 12) {
			dx += 32;
		}
		SetGraphicRect(dx, dy, dx + 32, dy + 32);
		DrawGraphic(GetX, GetY);
		dx = 0;
 	}
	@Finalize{
		loop(2) {
			CreateItem(ITEM_SCORE, GetX + rand(-50, 50), GetY - rand(20, 100));
		}
	}
    task SphereBloom(x, y, v, angle, accel, graphic1, graphic2, delay) {
	let obj = Obj_Create(OBJ_SHOT);
	let sdelay = 30;
	Obj_SetPosition(obj, x, y);
	Obj_SetAngle(obj, angle);
	Obj_SetSpeed(obj, v);
	ObjShot_SetGraphic(obj, graphic1);
	ObjShot_SetDelay(obj, sdelay);
	while(Obj_BeDeleted(obj) == false) {
		if(sdelay > 0) {
			sdelay--;
		}
		else if(Obj_GetSpeed(obj) > 0) {
			Obj_SetSpeed(obj, Obj_GetSpeed(obj) + accel);
		}
		else if(delay > 0) {
			Obj_SetSpeed(obj, 0);
			delay--;
		}
		else {
			ascent(a in 0..36) {
				CreateShot02(Obj_GetX(obj), Obj_GetY(obj), 0.5, a * 10 + angle + 180, 0.025, 2.5, graphic2, 10);
				CreateShot02(Obj_GetX(obj), Obj_GetY(obj), 0.5, a * 10 + angle + 180, 0.01, 1, graphic2, 10);
			}
			Obj_Delete(obj);
		}
		yield;
	}
  }
}