script_enemy_main {
	#include_function "lib\SHOT_REPLACE\shot_replace.dnh"
	let ImgPup1 = "script\img\enemysprites.png";
	let frame = 0;
	let angle = 270;
	let drawframe = 0;
	let GetPoint = true;
	@Initialize{
		SetLife(100);
		SetInvincibility(60);
		SetScore(1000);
		LoadGraphic(ImgPup1);
		SetTexture(ImgPup1);
        		SetGraphicRect(0, 0, 64, 64);
		shotinit;
	}
	function IsOffScreen {
		return GetX < GetClipMinX || GetX > GetClipMaxX || GetY < GetClipMinY || GetY > GetClipMaxY;
	}
	@MainLoop{
		SetCollisionA(GetX, GetY, 16);
		SetCollisionB(GetX, GetY, 8);
		yield;
		if(GetSpeed > 0) {
			SetSpeed(GetSpeed - 0.05);
		}
		else {
			SetSpeed(0);
		}
		if(frame < 16 && frame%2 == 1) {
			ascent(a in 0..9) {
				CreateShotA(0, GetX, GetY, 0);
				SetShotDataA(0, 0, 6, angle + a * 40, 0, -0.36, 0, GREEN21);
				SetShotDataA(0, 60, 2, angle + a * 40 - 90, 0, 0, 2, AQUA21);
				FireShot(0);
				CreateShotA(0, GetX, GetY, 0);
				SetShotDataA(0, 0, 6, angle + a * 40, 0, -0.36, 0, GREEN21);
				SetShotDataA(0, 60, 1, angle + a * 40 - 90, 0, 0, 1, AQUA21);
				FireShot(0);
			}
			angle += 5 * (GetArgument%2 * 2 - 1);
		}
		if(frame == 60) {
			let xfromc = GetCenterX - GetX;
			let absxfc = (|xfromc|);
			SetMovePositionHermite(GetX - 50 * (xfromc / absxfc), GetClipMinY - 50, 800, GetAngle, 800, GetAngle + 180, 120);
		}
		if(IsOffScreen && frame > 60) {
			GetPoint = false;
			VanishEnemy;
		}
		if(GetSpeed == 0) {
			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{
		if(GetPoint) {
			loop(5) {
				CreateItem(ITEM_SCORE,GetX+rand(-50,50),GetY - rand(20,100));
			}
		}
	}
}