//画像パス&読み込み(ファイルの構成が違う時は要変更)
	let imgHoutou_Beam_White = GetCurrentScriptDirectory ~ "img\Houtou2_Beam_add.png";
	let imgHoutou_Fire_White = GetCurrentScriptDirectory ~ "img\Houtou2_Fire_add.png";

	LoadGraphic(imgHoutou_Beam_White);
	LoadGraphic(imgHoutou_Fire_White);



//画像破棄(画像を破棄しないと気になる人用・コピーして使って下さい)
//	DeleteGraphic(imgHoutou_Beam_White);
//	DeleteGraphic(imgHoutou_Fire_White);



//宝塔ビーム(IDを返す)
//引数 1: X座標
//	   2: Y座標
//	   3: 角度
//	   4: 色(0〜7→赤〜白、8→虹色、9〜16→黒赤〜黒、17→黒虹)
//	   5: 遅延
//	   6: 消滅までの時間(フレーム指定)
	function Houtou(x, y, angle, color, delay, delTime) {
		let Obj    = Obj_Create(OBJ_EFFECT);

		Houtou_Beam(Obj, x, y, angle, color, delay, delTime, 1);
		return Obj;
	}



//宝塔ビーム制御
	task Houtou_Beam(Obj, x, y, angle, Color, delay, delTime, Render) {
		let Laser  = Obj_Create(OBJ_LASER);
		let Detail = Obj_Create(OBJ_EFFECT);
		let Fire   = Obj_Create(OBJ_EFFECT);

		let Length  = 0;
		let width   = 1;
		let grazeC  = 0;
		let color   = Color;
		let clrPlus = 0.25;
		let count   = 0;

		let Fire_count = 0;
		let Fire_scale = 1.5;
		let Fire_sclct = 0;

		let Rainbow = false;

		if(Color == 8) {
			color = 0;
			Rainbow = true;
		}

		let u = 0;
		let uPlus = -12.5;

//----------------------------------------------------------------------------------------------------
//基本設定

		Obj_SetPosition(Obj, x, y);
		ObjEffect_SetTexture(Obj, imgHoutou_Beam_White[Render]);
		ObjEffect_SetRenderState(Obj, ALPHA);
		ObjEffect_SetPrimitiveType(Obj, PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_SetScale(Obj, 1, width/40);
		ObjEffect_SetLayer(Obj, 2);

		Obj_SetPosition(Detail, x, y);
		ObjEffect_SetTexture(Detail, imgHoutou_Beam_White[Render]);
		ObjEffect_SetRenderState(Detail, ALPHA);
		ObjEffect_SetPrimitiveType(Detail, PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_SetScale(Detail, 1, width/40);
		ObjEffect_SetLayer(Detail, 2);

		Obj_SetPosition(Fire, Obj_GetX(Obj), Obj_GetY(Obj));
		ObjEffect_SetTexture(Fire, imgHoutou_Fire_White);
		ObjEffect_SetRenderState(Fire, ADD);
		ObjEffect_SetPrimitiveType(Fire, PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_SetScale(Fire, Fire_scale, Fire_scale);
		ObjEffect_SetLayer(Fire, 2);

		Obj_SetPosition(Laser, Obj_GetX(Obj), Obj_GetY(Obj));
		Obj_SetAngle(Laser, Obj_GetAngle(Obj));
		Obj_SetAlpha(Laser, 0);
		Obj_SetAutoDelete(Laser, false);
		ObjShot_SetGraphic(Laser, RED01);
		ObjShot_SetDelay(Laser, 0);
		ObjShot_SetBombResist(Laser, true);
		ObjShot_ToItem(Laser, false);
		ObjLaser_SetLength(Laser, 768);
		ObjLaser_SetWidth(Laser, width*(3/4));
		ObjLaser_SetSource(Laser, false);

		if(Render == 1) { ObjEffect_SetRenderState(Obj, ADD); }

//----------------------------------------------------------------------------------------------------
//エフェクト表示等の設定

		Obj_SetAngle(Obj, angle);
		ObjEffect_CreateVertex(Obj, 4);
		ObjEffect_SetVertexXY(Obj, 0,   0+5, -20);
		ObjEffect_SetVertexXY(Obj, 1,   0+5,  20);
		ObjEffect_SetVertexXY(Obj, 2, 768+5, -20);
		ObjEffect_SetVertexXY(Obj, 3, 768+5,  20);
		ObjEffect_SetVertexUV(Obj, 0, 128+(trunc(color)*16)   , 368);
		ObjEffect_SetVertexUV(Obj, 1, 128+(trunc(color)*16)+16, 368);
		ObjEffect_SetVertexUV(Obj, 2, 128+(trunc(color)*16)   , 384);
		ObjEffect_SetVertexUV(Obj, 3, 128+(trunc(color)*16)+16, 384);
		ObjEffect_SetAngle(Obj, 0, 0, Obj_GetAngle(Obj));

		ObjEffect_CreateVertex(Detail, 4);
		ObjEffect_SetVertexXY(Detail, 0,   0, -15);
		ObjEffect_SetVertexXY(Detail, 1,   0,  15);
		ObjEffect_SetVertexXY(Detail, 2, 768, -15);
		ObjEffect_SetVertexXY(Detail, 3, 768,  15);
		ObjEffect_SetVertexUV(Detail, 0,   0, 330);
		ObjEffect_SetVertexUV(Detail, 1,   0, 360);
		ObjEffect_SetVertexUV(Detail, 2, 768, 330);
		ObjEffect_SetVertexUV(Detail, 3, 768, 360);
		ObjEffect_SetAngle(Detail, 0, 0, Obj_GetAngle(Obj));

		ObjEffect_CreateVertex(Fire, 4);
		ObjEffect_SetVertexXY(Fire, 0,  -3, -64);
		ObjEffect_SetVertexXY(Fire, 1,  -3,  64);
		ObjEffect_SetVertexXY(Fire, 2, 124, -64);
		ObjEffect_SetVertexXY(Fire, 3, 124,  64);
		ObjEffect_SetAngle(Fire, 0, 0, Obj_GetAngle(Obj));

//----------------------------------------------------------------------------------------------------
//待機時間の処理部分

//		PlaySE(SEAppear);

		loop(delay) {
			if(Obj_BeDeleted(Obj) == true) { break; }
			if(Obj_BeDeleted(Laser)) { Laser = Obj_Create(OBJ_LASER); }

			ObjEffect_SetAngle(Obj, 0, 0, Obj_GetAngle(Obj));

			Obj_SetPosition(Detail, Obj_GetX(Obj), Obj_GetY(Obj));
			ObjEffect_SetAngle(Detail, 0, 0, Obj_GetAngle(Obj));

			if(trunc(Fire_count)%2 == 0) {
				ObjEffect_SetVertexUV(Fire, 0,  trunc(color/4)*256    ,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 1,  trunc(color/4)*256    , ((trunc(color)%4)*128)+128);
				ObjEffect_SetVertexUV(Fire, 2,  trunc(color/4)*256+127,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 3,  trunc(color/4)*256+127, ((trunc(color)%4)*128)+128);
			} else if(trunc(Fire_count)%2 == 1) {
				ObjEffect_SetVertexUV(Fire, 0,  trunc(color/4)*256+128,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 1,  trunc(color/4)*256+128, ((trunc(color)%4)*128)+128);
				ObjEffect_SetVertexUV(Fire, 2,  trunc(color/4)*256+255,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 3,  trunc(color/4)*256+255, ((trunc(color)%4)*128)+128);
			}

			Obj_SetPosition(Fire, Obj_GetX(Obj), Obj_GetY(Obj));
			ObjEffect_SetScale(Fire, Fire_scale+1.5*(1-Fire_sclct), Fire_scale*Fire_sclct);
			ObjEffect_SetAngle(Fire, 0, 0, Obj_GetAngle(Obj));

			Obj_SetPosition(Laser, Obj_GetX(Obj), Obj_GetY(Obj));
			Obj_SetAngle(Laser, Obj_GetAngle(Obj));
			ObjLaser_SetWidth(Laser, width*(5/4));

			Fire_count += 0.5;
			if(Fire_sclct < 1) { Fire_sclct += 0.2; }
			if(Rainbow) { color += clrPlus; }
			if(Rainbow && color >= 7)  { color = 0; }
			yield;
		};

//----------------------------------------------------------------------------------------------------
//発射する処理部分

		ObjEffect_SetScale(Obj, (Length/768), 1);
		ObjEffect_SetVertexUV(Obj, 0,      0, (trunc(color)*40)+5);
		ObjEffect_SetVertexUV(Obj, 1,      0, (trunc(color)*40)+45);
		ObjEffect_SetVertexUV(Obj, 2, Length, (trunc(color)*40)+5);
		ObjEffect_SetVertexUV(Obj, 3, Length, (trunc(color)*40)+45);
		ObjEffect_SetScale(Fire, Fire_scale, Fire_scale);
//		PlaySE(SELaser);

		loop(30) {
			if(Obj_BeDeleted(Obj) == true) { break; }
			if(Obj_BeDeleted(Laser)) { Laser = Obj_Create(OBJ_LASER); }

			Length += 20;
			if(width < 40) { width  += (39/15); } else { width = 40; }
			u += uPlus;

/*
			if( Collision_Line_Circle(Obj_GetX(Obj), Obj_GetY(Obj), x + 1000*cos(Obj_GetAngle(Obj)), y + 1000*sin(Obj_GetAngle(Obj)), width*(3/4), GetPlayerX, GetPlayerY, 0 ) == true &&
				GetTimeOfPlayerInvincibility == 0) {
					ShootDownPlayer;
			}

			if( Collision_Line_Circle(Obj_GetX(Obj), Obj_GetY(Obj), x + 1000*cos(Obj_GetAngle(Obj)), y + 1000*sin(Obj_GetAngle(Obj)), width*1.5, GetPlayerX, GetPlayerY, 0 ) == true &&
				GetTimeOfPlayerInvincibility == 0) {
					if(grazeC%6 == 0) { AddGraze(1); PlaySE("seGraze.wav"); }
					grazeC++;
			} else {
				grazeC = 0;
			}
*/

			ObjEffect_SetScale(Obj, (Length/768), width/40);
			ObjEffect_SetAngle(Obj, 0, 0, Obj_GetAngle(Obj));
			ObjEffect_SetVertexUV(Obj, 0,      0+(u/2), (trunc(color)*40)+5);
			ObjEffect_SetVertexUV(Obj, 1,      0+(u/2), (trunc(color)*40)+45);
			ObjEffect_SetVertexUV(Obj, 2, Length+(u/2), (trunc(color)*40)+5);
			ObjEffect_SetVertexUV(Obj, 3, Length+(u/2), (trunc(color)*40)+45);

			Obj_SetPosition(Detail, Obj_GetX(Obj), Obj_GetY(Obj));
			ObjEffect_SetScale(Detail, 1, width/40);
			ObjEffect_SetAngle(Detail, 0, 0, Obj_GetAngle(Obj));
			ObjEffect_SetVertexUV(Detail, 0,   0+u, 330);
			ObjEffect_SetVertexUV(Detail, 1,   0+u, 360);
			ObjEffect_SetVertexUV(Detail, 2, 768+u, 330);
			ObjEffect_SetVertexUV(Detail, 3, 768+u, 360);

			if(trunc(Fire_count)%2 == 0) {
				ObjEffect_SetVertexUV(Fire, 0,  trunc(color/4)*256    ,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 1,  trunc(color/4)*256    , ((trunc(color)%4)*128)+128);
				ObjEffect_SetVertexUV(Fire, 2,  trunc(color/4)*256+127,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 3,  trunc(color/4)*256+127, ((trunc(color)%4)*128)+128);
			} else if(trunc(Fire_count)%2 == 1) {
				ObjEffect_SetVertexUV(Fire, 0,  trunc(color/4)*256+128,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 1,  trunc(color/4)*256+128, ((trunc(color)%4)*128)+128);
				ObjEffect_SetVertexUV(Fire, 2,  trunc(color/4)*256+255,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 3,  trunc(color/4)*256+255, ((trunc(color)%4)*128)+128);
			}

			Obj_SetPosition(Fire, Obj_GetX(Obj), Obj_GetY(Obj));
			ObjEffect_SetAngle(Fire, 0, 0, Obj_GetAngle(Obj));

			Obj_SetPosition(Laser, Obj_GetX(Obj), Obj_GetY(Obj));
			Obj_SetAngle(Laser, Obj_GetAngle(Obj));
			ObjLaser_SetWidth(Laser, width*(5/4));

			Fire_count += 0.5;
			if(Rainbow) { color += clrPlus; }
			if(Rainbow && color >= 7)  { color = 0; }
			yield;
		}

//----------------------------------------------------------------------------------------------------
//発射し続ける処理部分

		Length = 768;
		ObjEffect_SetScale(Obj, (Length/768), 1);

		while(!Obj_BeDeleted(Obj)) {
			if(count >= delTime && delTime >= 0) { break; }
			if(Obj_BeDeleted(Laser)) { Laser = Obj_Create(OBJ_LASER); }
			u += uPlus;

/*
			if( Collision_Line_Circle(Obj_GetX(Obj), Obj_GetY(Obj), x + 1000*cos(Obj_GetAngle(Obj)), y + 1000*sin(Obj_GetAngle(Obj)), width*(3/4), GetPlayerX, GetPlayerY, 0 ) == true &&
				GetTimeOfPlayerInvincibility == 0) {
					ShootDownPlayer;
			}

			if( Collision_Line_Circle(Obj_GetX(Obj), Obj_GetY(Obj), x + 1000*cos(Obj_GetAngle(Obj)), y + 1000*sin(Obj_GetAngle(Obj)), width*1.5, GetPlayerX, GetPlayerY, 0 ) == true &&
				GetTimeOfPlayerInvincibility == 0) {
					if(grazeC%6 == 0) { AddGraze(1); PlaySE("seGraze.wav"); }
					grazeC++;
			} else {
				grazeC = 0;
			}
*/

			ObjEffect_SetAngle(Obj, 0, 0, Obj_GetAngle(Obj));
			ObjEffect_SetVertexUV(Obj, 0,      0+(u/2), (trunc(color)*40)+5);
			ObjEffect_SetVertexUV(Obj, 1,      0+(u/2), (trunc(color)*40)+45);
			ObjEffect_SetVertexUV(Obj, 2, Length+(u/2), (trunc(color)*40)+5);
			ObjEffect_SetVertexUV(Obj, 3, Length+(u/2), (trunc(color)*40)+45);

			Obj_SetPosition(Detail, Obj_GetX(Obj), Obj_GetY(Obj));
			ObjEffect_SetAngle(Detail, 0, 0, Obj_GetAngle(Obj));
			ObjEffect_SetVertexUV(Detail, 0,   0+u, 330);
			ObjEffect_SetVertexUV(Detail, 1,   0+u, 360);
			ObjEffect_SetVertexUV(Detail, 2, 768+u, 330);
			ObjEffect_SetVertexUV(Detail, 3, 768+u, 360);

			if(trunc(Fire_count)%2 == 0) {
				ObjEffect_SetVertexUV(Fire, 0,  trunc(color/4)*256    ,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 1,  trunc(color/4)*256    , ((trunc(color)%4)*128)+128);
				ObjEffect_SetVertexUV(Fire, 2,  trunc(color/4)*256+127,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 3,  trunc(color/4)*256+127, ((trunc(color)%4)*128)+128);
			} else if(trunc(Fire_count)%2 == 1) {
				ObjEffect_SetVertexUV(Fire, 0,  trunc(color/4)*256+128,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 1,  trunc(color/4)*256+128, ((trunc(color)%4)*128)+128);
				ObjEffect_SetVertexUV(Fire, 2,  trunc(color/4)*256+255,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 3,  trunc(color/4)*256+255, ((trunc(color)%4)*128)+128);
			}

			Obj_SetPosition(Fire, Obj_GetX(Obj), Obj_GetY(Obj));
			ObjEffect_SetAngle(Fire, 0, 0, Obj_GetAngle(Obj));

			Obj_SetPosition(Laser, Obj_GetX(Obj), Obj_GetY(Obj));
			Obj_SetAngle(Laser, Obj_GetAngle(Obj));
			ObjLaser_SetWidth(Laser, width*(5/4));

			Fire_count += 0.5;
			if(Rainbow) { color += clrPlus; }
			if(Rainbow && color >= 7)  { color = 0; }
			if(delTime >= 0) { count++; }
			yield;
		}

//----------------------------------------------------------------------------------------------------
//消滅処理部分

		loop(30) {
			if(Obj_BeDeleted(Obj) == true) { break; }
			if(Obj_BeDeleted(Laser)) { Laser = Obj_Create(OBJ_LASER); }

			width -= (4/3);
			u += uPlus;

/*
			if( Collision_Line_Circle(Obj_GetX(Obj), Obj_GetY(Obj), x + 1000*cos(Obj_GetAngle(Obj)), y + 1000*sin(Obj_GetAngle(Obj)), width*(3/4), GetPlayerX, GetPlayerY, 0 ) == true &&
				GetTimeOfPlayerInvincibility == 0) {
					ShootDownPlayer;
			}

			if( Collision_Line_Circle(Obj_GetX(Obj), Obj_GetY(Obj), x + 1000*cos(Obj_GetAngle(Obj)), y + 1000*sin(Obj_GetAngle(Obj)), width*1.5, GetPlayerX, GetPlayerY, 0 ) == true &&
				GetTimeOfPlayerInvincibility == 0) {
					if(grazeC%6 == 0) { AddGraze(1); PlaySE("seGraze.wav"); }
					grazeC++;
			} else {
				grazeC = 0;
			}
*/

			ObjEffect_SetScale(Obj, 1, width/40);
			ObjEffect_SetAngle(Obj, 0, 0, Obj_GetAngle(Obj));
			ObjEffect_SetVertexUV(Obj, 0,      0+(u/2), (trunc(color)*40)+5);
			ObjEffect_SetVertexUV(Obj, 1,      0+(u/2), (trunc(color)*40)+45);
			ObjEffect_SetVertexUV(Obj, 2, Length+(u/2), (trunc(color)*40)+5);
			ObjEffect_SetVertexUV(Obj, 3, Length+(u/2), (trunc(color)*40)+45);

			Obj_SetPosition(Detail, Obj_GetX(Obj), Obj_GetY(Obj));
			ObjEffect_SetScale(Detail, 1, width/40);
			ObjEffect_SetAngle(Detail, 0, 0, Obj_GetAngle(Obj));
			ObjEffect_SetVertexUV(Detail, 0,   0+u, 330);
			ObjEffect_SetVertexUV(Detail, 1,   0+u, 360);
			ObjEffect_SetVertexUV(Detail, 2, 768+u, 330);
			ObjEffect_SetVertexUV(Detail, 3, 768+u, 360);

			Obj_SetPosition(Fire, Obj_GetX(Obj), Obj_GetY(Obj));
			ObjEffect_SetAngle(Fire, 0, 0, Obj_GetAngle(Obj));
			ObjEffect_SetScale(Fire, Fire_scale, Fire_scale*(width/40));

			if(trunc(Fire_count)%2 == 0) {
				ObjEffect_SetVertexUV(Fire, 0,  trunc(color/4)*256    ,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 1,  trunc(color/4)*256    , ((trunc(color)%4)*128)+128);
				ObjEffect_SetVertexUV(Fire, 2,  trunc(color/4)*256+127,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 3,  trunc(color/4)*256+127, ((trunc(color)%4)*128)+128);
			} else if(trunc(Fire_count)%2 == 1) {
				ObjEffect_SetVertexUV(Fire, 0,  trunc(color/4)*256+128,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 1,  trunc(color/4)*256+128, ((trunc(color)%4)*128)+128);
				ObjEffect_SetVertexUV(Fire, 2,  trunc(color/4)*256+255,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 3,  trunc(color/4)*256+255, ((trunc(color)%4)*128)+128);
			}

			Obj_SetPosition(Laser, Obj_GetX(Obj), Obj_GetY(Obj));
			Obj_SetAngle(Laser, Obj_GetAngle(Obj));
			ObjLaser_SetWidth(Laser, width*(5/4));

			if(Rainbow) { color += clrPlus; }
			if(Rainbow && color >= 7)  { color = 0; }
			yield;
		}

		Obj_Delete(Obj);
		Obj_Delete(Fire);
		Obj_Delete(Detail);
		Obj_Delete(Laser);
	}
