// ぬえの基本設定＆関数まとめ

let imgNue = GetCurrentScriptDirectory() ~ "\img\effect_circle.png";

//実際の位置
let OF_X =	0;
let OF_Y =	0;


function wait(let frame)
{//待機関数
	loop(frame){yield};
}

//エフェクト設定ひとまとめ
sub start_nue
{
	effect_nue02;
	effect_nue01;
	TFuyoFuyo;
}

//ふよふよ動く
task TFuyoFuyo()
{
	let t = 0;
	loop
	{
		OF_X = sin(t*3)*24;
		OF_Y = sin(t*2)*24;
		t++;
		yield;
	}
}

// ぬえエフェクト
task effect_nue01
{
	//初期設定
	let X1 = 384;
	let X2 = 512;
	let Y1 = 384;
	let Y2 = 512;

	let obj = Obj_Create(OBJ_EFFECT);
	ObjEffect_SetTexture(obj, imgNue);
	ObjEffect_SetRenderState(obj, ADD);
	ObjEffect_SetLayer(obj, 2);
	ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
	ObjEffect_CreateVertex(obj, 4);
	ObjEffect_SetVertexUV(obj, 0, X1, Y1);
	ObjEffect_SetVertexUV(obj, 1, X2, Y1);
	ObjEffect_SetVertexUV(obj, 2, X2, Y2);
	ObjEffect_SetVertexUV(obj, 3, X1, Y2);
	ObjEffect_SetVertexXY(obj, 0, -100, -100);
	ObjEffect_SetVertexXY(obj, 1,  100, -100);
	ObjEffect_SetVertexXY(obj, 2,  100,  100);
	ObjEffect_SetVertexXY(obj, 3, -100,  100);

	ObjEffect_SetScale(obj, 0.4,0.4);

	//ずっとループのターン
	let angle = 0;
	loop
	{
		angle += 64;
		Obj_SetPosition(obj, GetX+OF_X, GetY+OF_Y);
		ObjEffect_SetAngle(obj, 0, 0, angle);
		yield;
	}

	Obj_Delete(obj);
}

task effect_nue02
{
	//初期設定
	let X1 = 385;
	let X2 = 512;
	let Y1 = 0;
	let Y2 = 128;

	let obj = Obj_Create(OBJ_EFFECT);
	ObjEffect_SetTexture(obj, imgNue);
	ObjEffect_SetRenderState(obj, ADD);
	ObjEffect_SetLayer(obj, 2);
	ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
	ObjEffect_CreateVertex(obj, 4);
	ObjEffect_SetVertexUV(obj, 0, X1, Y1);
	ObjEffect_SetVertexUV(obj, 1, X2, Y1);
	ObjEffect_SetVertexUV(obj, 2, X2, Y2);
	ObjEffect_SetVertexUV(obj, 3, X1, Y2);
	ObjEffect_SetVertexXY(obj, 0, -100, -100);
	ObjEffect_SetVertexXY(obj, 1,  100, -100);
	ObjEffect_SetVertexXY(obj, 2,  100,  100);
	ObjEffect_SetVertexXY(obj, 3, -100,  100);
	ascent (let n in 0 .. 4)
	{
		ObjEffect_SetVertexColor(obj, n, 128, 192, 192, 255);
	}

	ObjEffect_SetScale(obj, 0.6,0.6);

	//ずっとループのターン
	let angle = 0;
	loop
	{
		angle -= 65;
		Obj_SetPosition(obj, GetX+OF_X, GetY+OF_Y);
		ObjEffect_SetAngle(obj, 0, 0, angle);
		yield;
	}

	Obj_Delete(obj);
}
