//素材使用関数・双曲線系関数のリスト。

//自然対数の値（処理落ち防止のため精度１６桁）を取得します。
function E{
let e = 2.718281828459045;
return e;
}

//双曲線正弦を取得します
function Sinh(t){
let sinh = (E() ^ t - E() ~ t) / 2;
return sinh;
}

//双曲線余弦を取得します
function Cosh(t){
let cosh = (E() ^ t + E() ~ t) / 2;
return cosh;
}

//ここより下は素材ですので、上記の弾幕以外での使用禁止

function Allshot(speed,dir,way,bullet,delay){

ascent(let i in 0..way){
CreateShot01(GetX,GetY,speed,dir+(360/way*i),bullet,delay);
}
}


function AllshotXY(x,y,speed,dir,way,bullet,delay){

ascent(let i in 0..way){
CreateShot01(x,y,speed,dir+(360/way*i),bullet,delay);
}
}


function ReflectShot(x,y,speed,angle,reflectNum,reflectL,reflectU,reflectR,reflectD,graphic,delay){
	
let minX = GetClipMinX();
let maxX = GetClipMaxX();
let minY = GetClipMinY();
let maxY = GetClipMaxY();
let totalFrame = 0;
CreateShotA( 0, x, y, delay );
SetShotDataA( 0, 0, speed, angle, 0, 0, 0, graphic );
while( reflectNum >= 1 ){
	while( angle < 0 ){ angle += 360; }
	if( angle >= 360 ){ angle %= 360; }
	let angleLU = atan2( y - minY, x - minX ) + 180;
	let angleRU = atan2( y - minY, x - maxX ) + 180;
	let angleLD = atan2( y - maxY, x - minX ) + 180;
	let angleRD = atan2( y - maxY, x - maxX ) + 180;
	if( angleRU == 0 ){ angleRU = 360; }
	if( angleRD == 360 ){ angleRD = 0; }
	let reflectLength = 0;
	let reflectX = 0;
	let reflectY = 0;
	let reflectAngle = 0;
	let reflect = false;
	if( angle >= angleRU || angle < angleRD ){
		reflectLength = ( maxX - x ) / cos( angle );
		reflectX = maxX;
		reflectY = y + reflectLength * sin( angle );
		reflectAngle = 180 - angle;
		reflect = reflectR;}
	else if( angle >= angleLD && angle < angleLU ){
	reflectLength = ( minX - x ) / cos( angle );
	reflectX = minX;
	reflectY = y + reflectLength * sin( angle );
	reflectAngle = 180 - angle;
	reflect = reflectL;}
	else if( angle >= angleLU && angle < angleRU ){
	reflectLength = ( minY - y ) / sin( angle );
	reflectX = x + reflectLength * cos( angle );
	reflectY = minY;
	reflectAngle = - angle;
	reflect = reflectU;}
	else{reflectLength = ( maxY - y ) / sin( angle );
	reflectX = x + reflectLength * cos( angle );
	reflectY = maxY;
	reflectAngle = - angle;
	reflect = reflectD;}
	if( !reflect ){ break; }
	x = reflectX;
	y = reflectY;
	angle = reflectAngle;
	totalFrame += reflectLength / speed;
	SetShotDataA( 0, totalFrame, NULL, angle, 0, 0, 0, graphic );
	reflectNum --;}
	FireShot( 0 );}

function WideShot01(x,y,speed,angle,wideAngle,way,graphic,delay){
let wayAngle = 0;
if( way > 1 ){
	wayAngle = wideAngle / ( way - 1 );
	angle -= wideAngle / 2;}
loop( way ){CreateShot01( x, y, speed, angle, graphic, delay );
	angle += wayAngle;}
}

function GravityShot(x,y,speed,angle,grvSpeed,grvAngle,graphic,delay){
let xSpeed = speed * cos( angle );
let ySpeed = speed * sin( angle );
let accXSpeed = grvSpeed * cos( grvAngle );
let accYSpeed = grvSpeed * sin( grvAngle );
let maxXSpeed = [ 99, - 99 ][ accXSpeed < 0 ];
let maxYSpeed = [ 99, - 99 ][ accYSpeed < 0 ];
CreateShot12( x, y, xSpeed, ySpeed, accXSpeed, accYSpeed, maxXSpeed, maxYSpeed, graphic, delay );}