#include "./Index.txt"

function UFO(x,y, color){
let obj = ObjEnemy_Create(OBJ_ENEMY);
ObjEnemy_Regist(obj);
Render(obj, x, y, color);
return(obj);
	task Render(obj, x, y, color){
	let texture = GetCurrentScriptDirectory ~ "./img/UFO.png";
	let X = 64;
	let Y = 64;
	let frame = 0;
	
	let list = [64, 128, 192, 256, 320];
	let coloring = 0;
	if(color == "red"){coloring = list[0];}
	if(color == "blue"){coloring = list[1];}
	if(color == "green"){coloring = list[2];}
	if(color == "yellow"){coloring = list[3];}
	if(color == "white"){coloring = list[4];}
	
	ObjPrim_SetTexture(obj, texture);
	ObjSprite2D_SetSourceRect(obj,0,0,X,Y);
	ObjSprite2D_SetDestCenter(obj);	
	ObjRender_SetScaleXYZ(obj,1,1,0);
	ObjRender_SetAlpha(obj,255);
	ObjRender_SetAngleXYZ(obj,0,0,0);
	ObjRender_SetPosition(obj, x, y, 0);
	
		while(!Obj_IsDeleted(obj)){
		if(frame <= 8) {ObjSprite2D_SetSourceRect(obj,0,coloring-64,X,coloring);}
		if(frame >= 8) {ObjSprite2D_SetSourceRect(obj,X,coloring-64,X*2,coloring);}
		if(frame >= 12) {ObjSprite2D_SetSourceRect(obj,X*2,coloring-64,X*3,coloring);}
		if(frame >= 20) {ObjSprite2D_SetSourceRect(obj,X*3,coloring-64,X*4,coloring);}
		if(frame>28){frame=0;}
		frame++;
		yield;
		}
	}
}

function DarknessCloud(x,y){
let obj = ObjEnemy_Create(OBJ_ENEMY);
ObjEnemy_Regist(obj);
Render(obj, x, y);
return(obj);
	task Render(obj, x, y){
	let texture = GetCurrentScriptDirectory ~ "./img/Cloud.png";
	let X = 128;
	let Y = 128;
	ObjPrim_SetTexture(obj, texture);
	Obj_SetRenderPriorityI(obj, 80);
	ObjSprite2D_SetSourceRect(obj,0,0,X,Y);
	ObjSprite2D_SetDestCenter(obj);	
	ObjRender_SetScaleXYZ(obj,1,1,0);
	ObjRender_SetAlpha(obj,255);
	ObjRender_SetAngleXYZ(obj,0,0,0);
	ObjRender_SetPosition(obj, x, y, 0);
	//ObjRender_SetBlendType(obj, BLEND_);
	}
}