#include "./Index.txt"

function GravityPush(x,y, ang){
let obj = ObjEnemy_Create(OBJ_ENEMY);
ObjEnemy_Regist(obj);
Render(obj, x, y, ang);
Deletion(obj);
return(obj);
	task Render(obj, x, y, ang){
	let texture = GetCurrentScriptDirectory ~ "./img/Gravity2.png";
	let X = 800;
	let Y = 250;	
	let count = 0;
	ObjPrim_SetTexture(obj, texture);
	Obj_SetRenderPriorityI(obj, 60);
	ObjSprite2D_SetSourceRect(obj,0,0,X,Y);
	ObjSprite2D_SetDestCenter(obj);	
	ObjRender_SetScaleXYZ(obj,1,1,0);
	ObjRender_SetAlpha(obj,160);
	ObjRender_SetAngleXYZ(obj,0,0,ang);
	ObjRender_SetPosition(obj, x, y, 0);
	ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);
	
		while(!Obj_IsDeleted(obj)){
		ObjRender_SetColor(obj, 255*sin(count*5), 0, 255*sin(count*5) );
		count+=10;
		yield;
		}
	}
	task Deletion(obj){
		while(!Obj_IsDeleted(obj)){		
			if(trunc(ObjMove_GetX(obj))>GetStgFrameWidth+100){Obj_Delete(obj);}
			if(trunc(ObjMove_GetX(obj))<-100){	Obj_Delete(obj);}	
			if(trunc(ObjMove_GetY(obj))>GetStgFrameHeight+100){Obj_Delete(obj);}  
			if(trunc(ObjMove_GetY(obj))<-100){Obj_Delete(obj);}
			yield;
		}
	}
}

function GravityWell{
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	let texture = GetCurrentScriptDirectory ~ "./img/Gravity.png";
	ObjPrim_SetTexture(obj, texture);
	Obj_SetRenderPriorityI(obj, 40);
	ObjSprite2D_SetSourceRect(obj,0,0,55,55);
	ObjSprite2D_SetDestCenter(obj);	
	ObjRender_SetScaleXYZ(obj,1,1,0);
	ObjRender_SetAngleXYZ(obj,0,0,0);
	ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);
	ObjRender_SetColor(obj, 255, 255, 255);
	
	return obj;
	}

function Smoke(obj){
let cloud = ObjEnemy_Create(OBJ_ENEMY);
ObjEnemy_Regist(cloud);
Render(cloud, obj);
return(cloud);
	task Render(cloud, obj){
	let alpha = 255;
	let texture = GetCurrentScriptDirectory ~ "./img/smoke.png";
	ObjPrim_SetTexture(cloud, texture);
	Obj_SetRenderPriorityI(cloud, 40);
	ObjSprite2D_SetSourceRect(cloud,0,0,301,246);
	ObjSprite2D_SetDestCenter(cloud);	
	ObjRender_SetScaleXYZ(cloud,0.2,0.2,0);
	ObjRender_SetPosition(cloud, ObjMove_GetX(obj), ObjMove_GetY(obj), 0);
	ObjRender_SetAlpha(cloud, alpha);
	loop(60){
		alpha-=255/60;
		ObjRender_SetAlpha(obj,alpha);
	yield;}
	Obj_Delete(cloud);
	}
}