function FireShotA1(x, y, spd, ang, graph, del){
let obj = CreateShotA1(x, y, 0,ang,graph,0);
ObjShot_SetIntersectionEnable(obj, false);
Scale;
ObjMove_AddPatternA1(obj, del, spd, ang);

return obj;

	task Scale{
	let alpha = 0;
	let scale = 2.5;
		loop(del){
		ObjRender_SetAlpha(obj, alpha);
		ObjRender_SetScaleXYZ(obj, scale, scale, scale);
		alpha += 255/del;
		scale -= 1.5/del;
		yield;
		}
	ObjShot_SetIntersectionEnable(obj, true);
	}

}

function FireShotA2(x, y, spd, ang, acc, mspd, graph, del){
let obj = CreateShotA1(x, y, 0,ang,graph,0);
ObjShot_SetIntersectionEnable(obj, false);
Scale;
ObjMove_AddPatternA2(obj, del, spd, ang, acc, 0, mspd);

return obj;

	task Scale{
	let alpha = 0;
	let scale = 2.5;
		loop(del){
		ObjRender_SetAlpha(obj, alpha);
		ObjRender_SetScaleXYZ(obj, scale, scale, scale);
		alpha += 255/del;
		scale -= 1.5/del;
		yield;
		}
	ObjShot_SetIntersectionEnable(obj, true);
	}

}

function FireShotB1(x, y, X, Y, graph, del){
let obj = CreateShotB1(x, y, 0,0,graph,0);
ObjShot_SetIntersectionEnable(obj, false);
Scale;
ObjMove_AddPatternB1(obj, del, X, Y);

return obj;

	task Scale{
	let alpha = 0;
	let scale = 2.5;
		loop(del){
		ObjRender_SetAlpha(obj, alpha);
		ObjRender_SetScaleXYZ(obj, scale, scale, scale);
		alpha += 255/del;
		scale -= 1.5/del;
		yield;
		}
	ObjShot_SetIntersectionEnable(obj, true);
	}

}

function FireShotB2(x, y, X, Y, Xacc, Yacc, Xmax, Ymax, graph, del){
let obj = CreateShotB1(x, y, 0,0,graph,0);
ObjShot_SetIntersectionEnable(obj, false);
Scale;
ObjMove_AddPatternB2(obj, del, X, Y, Xacc, Yacc, Xmax, Ymax);

return obj;

	task Scale{
	let alpha = 0;
	let scale = 2.5;
		loop(del){
		ObjRender_SetAlpha(obj, alpha);
		ObjRender_SetScaleXYZ(obj, scale, scale, scale);
		alpha += 255/del;
		scale -= 1.5/del;
		yield;
		}
	ObjShot_SetIntersectionEnable(obj, true);
	}

}

/////////////////////////////////////////////////////////////////////
//Edges//
/////////////////////////////////////////////////////////////////////

function GetStageLeft{
let obj = 0;
return obj;
}

function GetStageRight{
let obj = GetStgFrameWidth;
return obj;
}

function GetStageUp{
let obj = 0;
return obj;
}

function GetStageDown{
let obj = GetStgFrameHeight;
return obj;
}

function GetCenterX{
let obj = GetStgFrameWidth/2;
return obj;
}

function GetCenterY{
let obj = GetStgFrameHeight/2;
return obj;
}

function GetRandomStageX{
let obj = rand(0,GetStgFrameWidth);
return obj;
}

function GetRandomStageY{
let obj = rand(0,GetStgFrameHeight);
return obj;
}

function IsObjInsideBox(obj){
let X = GetY(obj);
let Y = GetX(obj);
let check = true;
if(X > GetStageRight){check = false;}
if(X < GetStageLeft){check = false;}
if(Y > GetStageDown){check = false;}
if(Y < GetStageUp){check = false;}

return check;
}

/////////////////////////////////////////////////////////////////////
//Angles and Coordinates//
/////////////////////////////////////////////////////////////////////

function GetAngleToPoint(x1, y1, x2, y2){
let angle = atan2(y1 - y2, x1 - x2);
return angle;
}

function GetAngleToObject(obj, obj2){
let angle = atan2(ObjMove_GetY(obj)-ObjMove_GetY(obj2),ObjMove_GetX(obj)-ObjMove_GetX(obj2));
return angle;
}

function GetX(obj){
let a = ObjMove_GetX(obj);
return a;
}

function GetY(obj){
let a = ObjMove_GetY(obj);
return a;
}

/////////////////////////////////////////////////////////////////////
//Effects//
/////////////////////////////////////////////////////////////////////

task ShotReflect(obj, left, up, right, down, time){
	let count = 0;
	while(!Obj_IsDeleted(obj) && count < time){
	if(left == 1){
		if(GetX(obj) < GetStageLeft){
		ObjMove_SetX(obj,0);
		ObjMove_SetAngle(obj,180 - ObjMove_GetAngle(obj));
		count++;
		}
	}
	else{}
	if(right == 1){
		if(GetX(obj) > GetStageRight){
		ObjMove_SetX(obj,GetStageRight);
		ObjMove_SetAngle(obj,180 - ObjMove_GetAngle(obj));
		count++;
		}
	}
	else{}
	if(up == 1){
		if(GetY(obj) < GetStageUp){
		ObjMove_SetY(obj,0);
		ObjMove_SetAngle(obj,360 - ObjMove_GetAngle(obj));
		count++;
		}
	}
	else{}
	if(down == 1){
		if(GetY(obj) > GetStageDown){
		ObjMove_SetY(obj,GetStageDown);
		ObjMove_SetAngle(obj,360 - ObjMove_GetAngle(obj));
		count++;
		}
	}
	else{}
	yield;
	}
}
