script_enemy_main {
#include_function ".\lib.txt"
let imgAngle=0;
@Initialize{
    SetLife(10);
    LoadStuff;
	LoadUserShotData(GetCurrentScriptDirectory~"Shot.txt");
	MainTask;
	}
@MainLoop{
	imgAngle+=10;
    yield;
	}
@DrawLoop{
	SetAlpha(255);
	SetColor(255,255,255);
	SetGraphicAngle(0,0,imgAngle);
	SetTexture(Enemy);
	SetGraphicRect(32*((|GetArgument|)),0,32*((|GetArgument|)+1),32);
	DrawGraphic(GetX,GetY);
	}
@Finalize{
	DeleteStuff;
	}
task MainTask{
	loop{
		ascent (i in 6..11){
			Bullet(1, 0.5*i);
			Bullet(-1, 0.5*i);
			PlaySE(Shot1);
			}
		Wait(120);
		}
	}
task Bullet(side, speed){
	let obj=Obj_Create(OBJ_SHOT);
	let Bounce=false;
	Obj_SetPosition(obj, GetX, GetY);
    Obj_SetAngle(obj, 90+90*side+GetArgument*5);
    Obj_SetSpeed(obj, 3+speed*0.5);
    ObjShot_SetGraphic(obj, 179);
    ObjShot_SetDelay  (obj, 0);
    ObjShot_SetBombResist (obj, false);
	while(Obj_BeDeleted(obj)==false) {
		if(Obj_GetX(obj)<GetClipMinX && Bounce==false) {
			Obj_SetAngle(obj, GetRelativeAngleToPlayer(Obj_GetX(obj),Obj_GetY(obj)));
			Obj_SetX(obj,  Obj_GetX(obj) + 0.1);
			ObjShot_SetGraphic(obj, 181);
			Bounce = true;
			}
		if(Obj_GetX(obj)>GetClipMaxX && Bounce==false) {
			Obj_SetAngle(obj, GetRelativeAngleToPlayer(Obj_GetX(obj),Obj_GetY(obj)));
			Obj_SetX(obj,  Obj_GetX(obj) - 0.1);
			ObjShot_SetGraphic(obj, 182);
			Bounce=true;
			}
		yield;
		}
	}
}