let img=GetCurrentScriptDirectory~"img\stg5enm.png";
let img_bg=GetCurrentScriptDirectory~"img\cdbg05a.png";
let img_bgb=GetCurrentScriptDirectory~"img\cdbg05b.png";
let black=GetCurrentScriptDirectory~"img\black.png";
let imgb=GetCurrentScriptDirectory~"img\stg5enm2.png";
LoadGraphic(black);
LoadGraphic(img);
LoadGraphic(img_bg);
LoadGraphic(img_bgb);
LoadGraphic(imgb);
let anim=0;
let type=0;
let animb=0;
let bgdist=0;
let rot=0;
let drawangle=0;

sub anim2{
	anim=0;
	type=0;
    drawangle+=3;
    animb++;
    if(animb>=38){animb-=38;}
	SetTexture(img);
	if(GetSpeedX<0)
	{
	SetGraphicRect(64, 64, 128, 128);
	SetGraphicAngle(0, 0, 0);
	}else if(GetSpeedX<0){
	SetGraphicRect(64, 64, 128, 128);
	SetGraphicAngle(180, 0, 0);
	}else{
	SetGraphicRect(floor(animb/10)*64, 0, 64+floor(animb/10)*64, 64);
	SetGraphicAngle(0, 0, 0);
	}
	SetGraphicScale(1, 1);
	SetAlpha(255);
	DrawGraphic(GetX, GetY+8*sin(drawangle));
}
sub animcast{
	anim++;
    animb=0;
	if(anim%7==0)
	{
	type++;
	}
	if(type==2)
	{
	type=1;
	}
	SetTexture(img);
	SetGraphicRect(type*64, 128, 64+64*type, 192);
	SetGraphicAngle(0, 0, 0);
	SetGraphicScale(1, 1);
	SetAlpha(255);
	DrawGraphic(GetX, GetY);
}
sub fairy{
	SetTexture(imgb);
    if(GetSpeedX!=0){
        animb++;
        anim=0;
        if(animb>=27){animb=27;}
        SetGraphicRect(32*5+floor(animb/4)*32, 32, 32*6+floor(animb/4)*32, 64);
        if(GetSpeedX>0){SetGraphicAngle(0, 0, 0);}else{SetGraphicAngle(180, 0, 0);}
    }else{
        anim++;
        animb=0;
        if(anim>=19){anim-=19;}
        SetGraphicRect(floor(anim/4)*32, 32, 32+floor(anim/4)*32, 64);
        SetGraphicAngle(0, 0, 0);
    }
	SetGraphicScale(1, 1);
	SetAlpha(255);
	DrawGraphic(GetX, GetY);
}
sub fairydead{
	SetTexture(imgb);
    SetGraphicRect(32*4, 0, 32*5, 32);
    SetGraphicAngle(0, 0, 0);
	SetGraphicScale(1, 1);
	SetAlpha(255);
	DrawGraphic(GetX, GetY);
}
sub bg{
    bgdist++;
    if(bgdist>256){bgdist-=256;}
	SetTexture(black);
	SetGraphicRect(-1024, -1024, 1024, 1024);
	SetGraphicAngle(0, 0, 0);
    SetRenderState(ALPHA);
	SetAlpha(255);
	DrawGraphic(GetCenterX, GetCenterY);
	SetTexture(img_bg);
	SetGraphicRect(0, 0, 512, 512);
	SetGraphicAngle(0, 0, rot);
	SetGraphicScale(1, 1);
	SetAlpha(255);
	DrawGraphic(GetCenterX, GetCenterY);
	SetTexture(img_bgb);
	SetGraphicRect(-256, -512, 256, 512);
	SetGraphicAngle(0, 0, 0);
	SetGraphicScale(1, 1);
    SetRenderState(ADD);
	SetAlpha(100);
	DrawGraphic(GetCenterX, GetCenterY-bgdist);
	rot+=0.5;
    SetRenderState(ALPHA);
}