#東方弾幕風
#Title[童謡「天神様の細道」]
#Text[試作]
#ScriptVersion[2]
script_enemy_main
{
	let count=0;
	let cx=GetCenterX();//STGシーンの中心x座標を取得
	let cy=GetCenterY();//STGシーンの中心y座標を取得
	let imgExRumia=GetCurrentScriptDirectory~"img\ExRumia.png";
	let compus=GetCurrentScriptDirectory~"img\背景.png";
	let forest=GetCurrentScriptDirectory~"img\背景2.png";
	LoadUserShotData(GetCurrentScriptDirectory~"shot.txt");
	@Initialize
	{
		SetScore(30000);
		SetLife(500);
		SetDamageRate(10,8);
		SetMovePosition02(cx,cy-120,60);
		SetTimer(60);
		SetGraphicRect(1,1,64,64);
		SetInvincibility(60);
		LoadGraphic(imgExRumia);
		SetTexture(imgExRumia);	
		LoadGraphic(compus);
		LoadGraphic(forest);
		shottask;
		subtask;
		CutIn(YOUMU,"童謡「天神様の細道」",0,0,0,0,0);//スペルカード名表示
	}
	@MainLoop
	{
		yield;
		SetCollisionA(GetX(),GetY(),24);//当たり判定(自弾)登録
		SetCollisionB(GetX(),GetY(),24);//当たり判定(体当たり)登録
	}
	@Finalize
	{
		loop(8)
		{
			CreateItem(ITEM_SCORE,cx+rand(-100,100),rand(20,100));
		}
	}
	@DrawLoop
	{
		SetTexture(imgExRumia);	
		SetGraphicRect(1,1,64,64);
		SetGraphicScale(1,1);
		SetGraphicAngle(0,0,0);
		SetAlpha(255);
		DrawGraphic(GetX,GetY);
	}
	@BackGround
	{
		SetTexture(forest);	
		SetGraphicRect(1,1,450,294);
		SetAlpha(255);
		SetGraphicScale(1.55,1.55);
		SetGraphicAngle(0,0,0);
		DrawGraphic(cx,cy);
		SetTexture(compus);	
		SetGraphicRect(1,1,750,720);
		SetAlpha(255);
		SetGraphicScale(0.5,0.5);
		SetGraphicAngle(0,0,count);
		DrawGraphic(cx,cy);
		count++;
	}
	task shottask
	{
		let s=0;
		wait(120);
		loop
		{
			shot(s,rand(GetClipMinX,GetClipMaxX),GetClipMaxY,2,270);
			shot(s,rand(GetClipMinX,GetClipMaxX),GetClipMinY,1,90);
			wait(4);
		}
	}
	task subtask
	{
		wait(120);
		loop
		{
			if(GetKeyState(VK_UP)==KEY_HOLD)
			{
				SetPlayerY(GetPlayerY-2);
			}
			else if(GetKeyState(VK_DOWN)==KEY_HOLD)
			{
				SetPlayerY(GetPlayerY-1);
			}
			yield;
		}
	}
	function shot(let shotid,let shotx,let shoty,let speed,let angle)
	{
		CreateShotA(shotid,shotx,shoty,0);
		SetShotDirectionType(ABSOLUTE);
		SetShotDataA(shotid,0,speed,angle,0,0,0,112);
		FireShot(shotid);
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}