#e[Player]
#ScriptVersion[2]
#Menu[reimu]
#Text[]
#ReplayName[reimu]

script_player_main{
	let img=[
		GetCurrentScriptDirectory~"reimu.png",
		GetCurrentScriptDirectory~"effect.png",
	];
	let obj=NULL;
	
	@Initialize{
		SetPlayerLifeImage(img[0],0,0,48,48);
		SetSpeed(16,16);
		ascent(n in 0..length(img)){LoadGraphic(img[n]);}
		Main;
	}
	
	@MainLoop{
		SetIntersectionCircle(GetPlayerX,GetPlayerY,0);
		yield;
	}
	
	@Missed{
		yield;
	}
	
	@SpellCard{
	}
	
	@DrawLoop{
		SetTexture(img[0]);
		SetGraphicRect(0,0,48,48);
		DrawGraphic(GetPlayerX,GetPlayerY);
		if(!Obj_BeDeleted(obj)){Obj_SetPosition(obj,GetPlayerX,GetPlayerY);}
	}
	
	@Finalize{
		ascent(n in 0..length(img)){DeleteGraphic(img[n]);}
	}

	task Main{
		yield;
		BarrierEffect;
	}
	
	task BarrierEffect{
		obj=Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,img[1]);
		ObjEffect_SetPrimitiveType(obj,PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_SetRenderState(obj,ADD);
		ObjEffect_SetLayer(obj,2);
		ObjEffect_CreateVertex(obj,4);
		ObjEffect_SetVertexUV(obj,0,0,0);
		ObjEffect_SetVertexUV(obj,1,0,64);
		ObjEffect_SetVertexUV(obj,2,64,0);
		ObjEffect_SetVertexUV(obj,3,64,64);
		ObjEffect_SetVertexXY(obj,0,-32,-32);
		ObjEffect_SetVertexXY(obj,1,-32,32);
		ObjEffect_SetVertexXY(obj,2,32,-32);
		ObjEffect_SetVertexXY(obj,3,32,32);
		while(!Obj_BeDeleted(obj)){
			if(OnMissed){
				ascent(n in 0..4){ObjEffect_SetVertexColor(obj,n,0,255,255,255);}
			}else{
				ascent(n in 0..4){ObjEffect_SetVertexColor(obj,n,127,255,255,255);}
			}
			yield;
		}
	}
}