#東方弾幕風[Stage]
#Title[★おまけステージ０１]
#Text[解放条件：
レミリアと戦う

自機選択時Userキー：
敵強化]
#Player[FREE]
#ScriptVersion[2]
#BackGround[Default]
#BGM[]

script_stage_main
{
    let Z=0;
    let Z01=0;
    let gra=0;
    let gra2=0;
    let gra3=0;
    let cx=GetCenterX();
    let cy=GetCenterY();
    let AC=0;
    let ac=0;
    let count=0;
    let BGstep=0;
    let Yspeed=0;
    let Yspeed2=0;
    let slow=0;
    let slow2=0;
    let SlowMove=0;
    let uprr=0;
    let borr=0;
    let uprr2=0;
    let borr2=0;
    let uprr3=0;
    let borr3=0;
    let uprrS=0;
    let borrS=0;
    let BGG00=0;
    let BGG01=0;
    let BGG02=0;
    let BGG03=0;
    let BGG04=0;
    let BGG05=255;
    let BGG06=0;
    let BGG08=0;
    let BGG09=0;
    let BGG12=0;
    let ma=0;
    let xUP=500;
    let pass=GetCurrentScriptDirectory~"Spell.dat";
    let BG=100;
    let stage=0;
    let Dark=0;
    let mo=255;
    let Level=0;
    CompileEnemyFromFile(GetCurrentScriptDirectory~"RemiN01.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Remi01+.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Servant00.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Servant01.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Servant02.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Servant03.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Servant04.txt");
    task itemg()
    {
        let alpha = 0;
        let obj = Obj_Create(OBJ_EFFECT);
        Obj_SetX(obj, 605);
        Obj_SetY(obj, 193);
        Obj_SetSpeed(obj, 0);
        ObjEffect_SetTexture(obj, GetCurrentScriptDirectory~"\img\Tiiiiilllll.png");
        ObjEffect_SetRenderState(obj, ALPHA);
        ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
        ObjEffect_SetScale(obj,1,1);
        ObjEffect_SetAngle(obj,0,0,0);
        ObjEffect_CreateVertex(obj, 4);
        ObjEffect_SetLayer(obj,8);

        //四角形状に各頂点のUV値を設定
        ObjEffect_SetVertexUV(obj,0,176,352);
        ObjEffect_SetVertexUV(obj,1,176,384);
        ObjEffect_SetVertexUV(obj,2,192,384);
        ObjEffect_SetVertexUV(obj,3,192,352);

        while (!Obj_BeDeleted(obj))
        {

            //四角形状に各頂点の座標を設定
            ObjEffect_SetVertexXY(obj,0,0,0);
            ObjEffect_SetVertexXY(obj,1,0,32);
            ObjEffect_SetVertexXY(obj,2,16,32);
            ObjEffect_SetVertexXY(obj,3,16,0);

            ascent(let t in 0..4) {
                ObjEffect_SetVertexColor(obj,t,255,255,255,255);
            }

            if (uprr2<=0) {
                Obj_Delete(obj);
            }

            yield;
        }

    }

    task itemg2()
    {
        let alpha = 0;
        let obj = Obj_Create(OBJ_EFFECT);
        Obj_SetX(obj, 629);
        Obj_SetY(obj, 211);
        Obj_SetSpeed(obj, 0);
        ObjEffect_SetTexture(obj, GetCurrentScriptDirectory~"\img\Tiiiiilllll.png");
        ObjEffect_SetRenderState(obj, ALPHA);
        ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
        ObjEffect_SetScale(obj,0.5,0.5);
        ObjEffect_SetAngle(obj,0,0,0);
        ObjEffect_CreateVertex(obj, 4);
        ObjEffect_SetLayer(obj,8);

        while (!Obj_BeDeleted(obj))
        {

            //四角形状に各頂点の座標を設定
            ObjEffect_SetVertexXY(obj,0,-10,-19);
            ObjEffect_SetVertexXY(obj,1,-10,19);
            ObjEffect_SetVertexXY(obj,2,10,-19);
            ObjEffect_SetVertexXY(obj,3,10,19);

            //四角形状に各頂点のUV値を設定
            ObjEffect_SetVertexUV(obj,0,164+24*uprr,128);
            ObjEffect_SetVertexUV(obj,1,164+24*uprr,166);
            ObjEffect_SetVertexUV(obj,2,184+24*uprr,128);
            ObjEffect_SetVertexUV(obj,3,184+24*uprr,166);

            ascent(let t in 0..4) {
                ObjEffect_SetVertexColor(obj,t,255,255,255,255);
            }

            if (uprr2<=0) {
                Obj_Delete(obj);
            }

            yield;
        }

    }

    task StageTask
    {
        function Wait(let frame) {
            loop(frame) {
                yield
            };
        }
        function WaitForZeroEnemy() {
            while (GetEnemyNum() != 0) {
                yield;
            }
        }
        if (GetKeyState(VK_USER)==KEY_HOLD) {
            SetCommonData("ii1",2500);
        }
        Wait(1);CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy00.txt",cx,-512,0,0,13);

        Wait(19);PlaySE(GetCurrentScriptDirectory~"\se\metal.wav");

        BGstep=4;
        SetViewTo(0, 0, 0);
        SetViewFrom(1200, 90, 45);

        Wait(220);
        if (GetCommonDataDefaultEx("Spell","omake01",0)==0) {
            Wait(220);
            CreateEnemyFromFile(GetCurrentScriptDirectory~"LastEvent3.txt",0,0,0,0,0);
            Wait(300);
            Clear();
        }
        PlayMusic(GetCurrentScriptDirectory~"\bgm\bgm2.mp3");
        Wait(60);

        if (GetCommonDataDefault("ii1",0)>=2000) {
            CreateEnemyBossFromFile(GetCurrentScriptDirectory~"RemiP.txt",cx,-50,0,0,0);
            WaitForZeroEnemy();
            PlaySE(GetCurrentScriptDirectory~"\se\Baaaan.wav");
            Wait(80);
            CreateEnemyBossFromFile(GetCurrentScriptDirectory~"RemiP4.txt",cx,-116,0,0,0);
            WaitForZeroEnemy();
            PlaySE(GetCurrentScriptDirectory~"\se\Baaaan.wav");
            Wait(120);
            CreateEnemyBossFromFile(GetCurrentScriptDirectory~"RemiP2.txt",cx,0,0,0,0);
            WaitForZeroEnemy();
                PlaySE(GetCurrentScriptDirectory~"\se\bom13.wav");
                SetCommonData("flash2",255);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",GetCommonDataDefault("x",0),GetCommonDataDefault("y",0),0,0,4);
                Wait(20);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",GetCommonDataDefault("x",0)+64,GetCommonDataDefault("y",0)-22,0,0,3);
                Wait(20);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",GetCommonDataDefault("x",0)-64,GetCommonDataDefault("y",0)+22,0,0,3);
            Wait(120);
            FadeOutMusic(GetCurrentScriptDirectory~"\bgm\bgm2.mp3",8);
        }

        else {
            CreateEnemyBossFromFile(GetCurrentScriptDirectory~"RemiP.txt",cx,-50,0,0,0);
            PlayMusic(GetCurrentScriptDirectory~"\bgm\bgm2.mp3");
            WaitForZeroEnemy();
            PlaySE(GetCurrentScriptDirectory~"\se\Baaaan.wav");
            Wait(80);
            CreateEnemyBossFromFile(GetCurrentScriptDirectory~"RemiP5.txt",cx,-116,0,0,0);
            WaitForZeroEnemy();
                PlaySE(GetCurrentScriptDirectory~"\se\bom13.wav");
                SetCommonData("flash2",255);
                CollectItems;
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",GetCommonDataDefault("x",0),GetCommonDataDefault("y",0),0,0,4);
                Wait(20);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",GetCommonDataDefault("x",0)+64,GetCommonDataDefault("y",0)-22,0,0,3);
                Wait(20);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",GetCommonDataDefault("x",0)-64,GetCommonDataDefault("y",0)+22,0,0,3);
            Wait(120);
            FadeOutMusic(GetCurrentScriptDirectory~"\bgm\bgm2.mp3",8);
        }
        Wait(300);BGstep=5;Wait(120);
        Clear();


        Wait(64);

    }

    @Initialize()
    {
        if (IsCommonDataAreaExists("Spell")==false) {
            CreateCommonDataArea("Spell");
        }
        if (GetPlayerType()==REIMU_A || GetPlayerType()==REIMU_B || GetPlayerType()==MARISA_A || GetPlayerType()==MARISA_B) {
            BGG12=1;
        }

        LoadCommonDataEx("Spell",pass);
        LoadSE(GetCurrentScriptDirectory~"\se\Shot00.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\Shot01.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\Shot02.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\Shot03.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\Shot04.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\Shot05.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\Laser.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\Laser2.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\Laser3.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\puu81.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\puu811.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\Baaaaaaaan.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\Baaan.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\mizu08.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\metal.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\metal37_b.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\crash16_c.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\bom13.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\power33.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\eco00.wav");
        LoadGraphic(GetCurrentScriptDirectory~"shot_all.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\dot-kaze-ti.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\st00.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\st03.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\st04.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\st05.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\st06.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\moon3-1.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\moon3-2.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\moon3-3.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\moon3-4.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\NuclearWave2.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\circle_l.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\cloud.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\Title2.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\Tiiiiilllll.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\getitemborder.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\familiar.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\dot_remilia.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\dot_flandre.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\remilia2.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\NuclearSpark2.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\NuclearRing.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\NuclearRing2.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\ba1.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\ba2.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\ba3.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\ba4.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\3a.png");
        SetCommonData("ii1",0);
        SetCommonData("ii2",0);
        SetCommonData("ii3",0);
        SetCommonData("x",0);
        SetCommonData("y",0);
        SetCommonData("fs",0);
        SetCommonData("ddffffffffrrr",0);
        SetCommonData("last",false);
        SetCommonData("flash",0);
        SetCommonData("flash2",0);
        SetCommonData("Black",0);
        SetCommonData("Zatsuyou",0);
        SetCommonData("Zatsuyou2",0);
        SetCommonData("Go",0);
        SetCommonData("Mode",0);
        SetCommonData("P01",0);
        SetCommonData("P02",0);
        SetCommonData("P03",0);
        SetCommonData("P04",0);
        SetCommonData("bgh",0);
        if (GetCommonDataDefaultEx("Spell","omake01",0)==0) {
            SetCommonDataEx("Spell","omake01",0);
        }
        if (GetCommonDataDefaultEx("Spell","omake02",0)==0) {
            SetCommonDataEx("Spell","omake02",0);
        }
        if (GetCommonDataDefaultEx("Spell","omake03",0)==0) {
            SetCommonDataEx("Spell","omake03",0);
        }
        ExpertEx(false,0,7);
        SetRateScoreSystemEnable(false);
        SetShotAutoDeleteClip(32,32,32,32);
        SetNormPoint(-1);
        StageTask();
    }

    @MainLoop()
    {
        if (BGG12==1) {
            if (GetKeyState(VK_SHOT)==KEY_PUSH||GetKeyState(VK_SHOT)==KEY_HOLD) {
                ForbidShot(false);
            }
            else {
                ForbidShot(true);
            }
        }

        if (!OnPlayerMissed) {
            if (GetKeyState(VK_SLOWMOVE)==KEY_HOLD) {
                if (ma<250) {
                    ma+=10;
                }
            }else {
                if (ma>0) {
                    ma-=10;
                }
            }
        }
        if (OnPlayerMissed) {
            if (ma>0) {
                ma-=10;
            }
        }

        if (GetCommonDataDefault("ddffffffffrrr",0)==0) {
            if (gra3-GetGraze()<0) {
                gra++;
                gra2=18;
            }gra3=GetGraze();
            if (gra>16) {
                gra=16;
            }if (gra>0&&gra2<0) {
                gra--;
                gra2=18;
            }gra2--;
            if (gra>10&&count%8==0) {
                CollectItems;
            }

            if (count<110) {
                gra=16;
            }if (count==110) {
                gra=0;
            }if (OnBomb==true) {
                gra=12;
            }
            if (GetPlayerType()==REIMU_A || GetPlayerType()==REIMU_B) {
                if (GetPlayerY()<162) {
                    gra=11;
                }
            }
            else if (GetPlayerType()==MARISA_A || GetPlayerType()==MARISA_B) {
                if (GetPlayerY()<178) {
                    gra=11;
                }
            }
            else {
                if (GetPlayerY()<166) {
                    gra=11;
                }
            }
        }

        //０：廊下・背景　３：タイトル　４：レミリア・背景　５：ベース・黒　８：フラン・虹　９：フラン・黒

        if (BGstep==4) {
            if (BGG00>0) {
                BGG00-=2;
            }if (BGG01>0) {
                BGG01-=1;
            }if (BGG02>0) {
                BGG02-=1;
            }if (BGG03>0) {
                BGG03-=3;
            }if (BGG05>0) {
                BGG05-=1;
            }if (BGG04<255) {
                BGG04+=1;
            }
            if (BGG06>0) {
                BGG06-=1;
            }if (BGG08>0) {
                BGG08-=1;
            }if (BGG09>0) {
                BGG09-=1;
            }
        }
        if (OnEnemySpell==true) {
            if (BG>2) {
                BG-=2;
            }SetCommonData("Black",0);
        }else {
            BG=100;
        }

        if (GetEnemyLife<=0) {
            BG=100;
        }

        if (Dark<GetCommonDataDefault("Black",0)) {
            Dark++;
        }
        if (Dark>GetCommonDataDefault("Black",0)) {
            Dark-=5;
        }

        if (GetCommonDataDefault("flash2",0)>0) {
            SetCommonData("flash2",GetCommonDataDefault("flash2",0)-3);
        }

        if (uprrS==0) {
            if (GetPlayerLife()>=8&&uprr<9) {
                uprr3++;
            }
            if (GetPlayerLife()>=8&&uprr3>60) {
                uprr++;
                uprr3=0;
                ExtendPlayer(-1);
                PlaySE(GetCurrentScriptDirectory~"\se\power34.wav");
            }
            if (GetPlayerLife()<7&&uprr>0) {
                uprr--;
                ExtendPlayer(1);
            }
            if (uprr2<=0&&uprr>0) {
                uprr2++;
                itemg;
                itemg2;
            }
            if (uprr2>0&&uprr<=0) {
                uprr2--;
            }
            if (uprr>8) {
                uprr=0;
                uprrS=1;
            }
        }

        if (Yspeed2>Yspeed) {
            Yspeed+=0.01;
        }if (Yspeed2<Yspeed) {
            Yspeed-=0.01;
        }
        ac+=Yspeed;
        ac=ac%(488*3);
        count++;
        slow2--;
        Z++;
        yield;
    }

    @Finalize()
    {
        SaveCommonDataEx("Spell",pass);
        Slow(0);
        DeleteSE(GetCurrentScriptDirectory~"\se\Shot00.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\Shot01.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\Shot03.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\Shot04.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\Shot05.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\Shot06.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\Laser.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\Laser2.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\Laser3.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\puu81.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\puu811.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\Baaaaaaaan.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\Baaan.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\mizu08.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\metal.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\metal37_b.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\crash16_c.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\bom13.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\power33.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\eco00.wav");
        DeleteMusic(GetCurrentScriptDirectory~"\bgm\bgm1.mp3");
        DeleteMusic(GetCurrentScriptDirectory~"\bgm\bgm2.mp3");
        DeleteMusic(GetCurrentScriptDirectory~"\bgm\bgm3.mp3");
        DeleteMusic(GetCurrentScriptDirectory~"\bgm\bgm4.mp3");
        DeleteMusic(GetCurrentScriptDirectory~"\bgm\bgm5.mp3");
        DeleteGraphic(GetCurrentScriptDirectory~"shot_all.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\dot-kaze-ti.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\st00.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\st03.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\st04.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\st05.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\st06.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\3a.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\moon3-1.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\moon3-2.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\moon3-3.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\moon3-4.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\NuclearWave2.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\cloud.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\Title.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\Tiiiiilllll.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\getitemborder.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\familiar.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\circle_l.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\dot_remilia.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\dot_flandre.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\remilia2.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\NuclearSpark2.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\NuclearRing.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\NuclearRing2.png");
        DeleteCommonData("ii1");
        DeleteCommonData("ii2");
        DeleteCommonData("ii3");
        DeleteCommonData("x");
        DeleteCommonData("y");
        DeleteCommonData("fs");
        DeleteCommonData("ddffffffffrrr");
        DeleteCommonData("last");
        DeleteCommonData("flash");
        DeleteCommonData("flash2");
        DeleteCommonData("Black");
        DeleteCommonData("Zatsuyou");
        DeleteCommonData("Zatsuyou2");
        DeleteCommonData("Go");
        DeleteCommonData("Mode");
        DeleteCommonData("P01");
        DeleteCommonData("P02");
        DeleteCommonData("P03");
        DeleteCommonData("P04");
        DeleteCommonData("bgh");
    }

    @DrawTopObject() {
        if (GetCommonDataDefault("ddffffffffrrr",0)==0) {
            SetTexture(GetCurrentScriptDirectory~"\img\Tiiiiilllll.png");
            if (gra<=10) {
                SetGraphicRect(0,32*gra,64,32+32*gra);
            }
            if (gra<=0) {
                SetGraphicRect(0,0,64,32);
            }
            if (gra>10&&count%8>=0) {
                SetGraphicRect(0,352,64,384);
            }
            if (gra>10&&count%8>=4) {
                SetGraphicRect(0,384,64,416);
            }
            SetGraphicScale(1,1);
            SetAlpha(255);
            SetColor(mo,mo,mo);
            if (GetPlayerX()<160&&GetPlayerY()>332) {
                if (mo>50) {
                    mo-=4;
                }
            }
            if (GetPlayerX()>=160||GetPlayerY()<=332) {
                if (mo<255) {
                    mo+=4;
                }
            }
            SetRenderState(ADD);
            DrawGraphic(74,440);

            SetTexture(GetCurrentScriptDirectory~"shot_all.png");
            SetGraphicRect(0, 290, 28, 317);
            SetGraphicScale(0.42,0.4);
            SetAlpha(255);
            SetColor(255,255,255);
            if (ma<255) {
                SetAlpha(ma);
            }
            SetRenderState(ALPHA);
            DrawGraphic(GetPlayerX+1,GetPlayerY);
        }

        if (BGG03>0) {
            SetTexture(GetCurrentScriptDirectory~"\img\Title2.png");
            SetGraphicRect(0,0,512,512);
            SetGraphicScale(1,1);
            SetAlpha(255);
            SetColor(255,255,255);
            if (BGG03<255) {
                SetAlpha(BGG03);
            }
            SetRenderState(ALPHA);
            DrawGraphic(cx,cy);
        }

        if (count<=110) {
            SetTexture(GetCurrentScriptDirectory~"\img\getitemborder.png");
            if (count%8>=0) {
                SetGraphicRect(0,0,512,64);
            }
            if (count%8>=4) {
                SetGraphicRect(0,64,512,128);
            }
            SetGraphicAngle(0,0,0);
            SetGraphicScale(1,1);
            SetAlpha(255);
            SetColor(255,255,255);
            if (count>=80) {
                SetColor(255-(count-80)*8,255-(count-80)*8,255-(count-80)*8);
            }
            if (count<=30) {
                SetColor(count*8,count*8,count*8);
            }
            SetRenderState(ADD);
            if (GetPlayerType()==REIMU_A || GetPlayerType()==REIMU_B) {
                DrawGraphic(cx+5,162);
            }
            else if (GetPlayerType()==MARISA_A || GetPlayerType()==MARISA_B) {
                DrawGraphic(cx+5,178);
            }
            else {
                DrawGraphic(cx+5,166);
            }
        }

        if (GetCommonDataDefault("flash2",0)>0) {
            SetTexture(GetCurrentScriptDirectory~"\img\3a.png");
            SetGraphicRect(0,0,384,448);
            SetRenderState(ADD);
            SetGraphicScale(GetCommonDataDefault("flash2",0)/255,1);
            SetGraphicAngle(0,0,0);
            SetColor(GetCommonDataDefault("flash2",0),0,0);
            SetAlpha(255);
            DrawGraphic(GetCenterX(),GetCenterY());
        }

    }

    @DrawBottomObject() {

        if (BGG05>0) {//ベース・黒
            SetTexture(GetCurrentScriptDirectory~"\img\st00.png");
            SetGraphicRect(0,0,384,448);
            SetRenderState(ALPHA);
            SetGraphicScale(1,1);
            SetGraphicAngle(0,0,0);
            SetColor(255,255,255);
            SetAlpha(BGG05);
            DrawGraphic(GetCenterX(),GetCenterY());
        }

        if (BGG04>0) {//レミリア・背景
            SetTexture(GetCurrentScriptDirectory~"\img\st00.png");//闇
            SetGraphicRect(0,0,384,448);
            SetGraphicScale(1,1);
            SetGraphicAngle(0,0,0);
            SetAlpha(255);
            SetColor(255,255,255);
            SetAlpha(BGG05*0.7*(BG/100));
            SetRenderState(ALPHA);
            DrawGraphic(GetCenterX(),GetCenterY());
            SetGraphicScale(1.1,1.1);
            DrawGraphic(GetCenterX(),GetCenterY());

            SetTexture(GetCurrentScriptDirectory~"\img\moon3-3.png");//闇
            SetGraphicScale(1.3+0.1*sin(count*2),1.3+0.1*sin(count*2));
            SetGraphicRect(0,0,384,488);
            SetAlpha(255);
            SetColor(BGG04*(BG/100),BGG04*(BG/100),BGG04*(BG/100));
            SetRenderState(SUBTRACT);
            DrawGraphic(cx,cy-5);
            SetGraphicScale(1.4+0.1*sin(count*2),1.4+0.1*sin(count*2));
            DrawGraphic(cx,cy-11);

            //SetTexture(GetCurrentScriptDirectory~"\img\moon3-2.png");//月
            //SetGraphicScale(0.88-0.05*sin(count*0.5),0.88-0.05*sin(count*0.5));
            //SetGraphicRect(0,0,-512,-512);
            //SetAlpha(255);
            //SetColor(BGG04*0.15*(BG/100),BGG04*0.15*(BG/100),BGG04*0.15*(BG/100));
            //SetRenderState(ADD);
            //DrawGraphic(cx,cy+215);
        }

        if (Dark>0) {//レミリア通常・黒
            SetTexture(GetCurrentScriptDirectory~"\img\st00.png");
            SetGraphicRect(0,0,384,448);
            SetRenderState(ALPHA);
            SetGraphicScale(1,1);
            SetGraphicAngle(0,0,0);
            SetColor(255,255,255);
            SetAlpha(Dark+8);
            DrawGraphic(GetCenterX(),GetCenterY());
        }

        if (BGG04>0) {//レミリア・背景
            SetTexture(GetCurrentScriptDirectory~"\img\moon3-2.png");//月
            SetGraphicScale(0.66,0.66);
            SetGraphicRect(0,0,512,512);
            SetAlpha(255);
            SetColor(BGG04*0.5*(BG/100),BGG04*0.5*(BG/100),BGG04*0.5*(BG/100));
            SetRenderState(ADD);
            DrawGraphic(cx,cy-122);
            SetTexture(GetCurrentScriptDirectory~"\img\moon3-4.png");//月
            SetGraphicScale(0.82+0.05*sin(count*0.5),0.82+0.05*sin(count*0.5));
            SetColor(BGG04*0.3*(BG/100),BGG04*0.3*(BG/100),BGG04*0.3*(BG/100));
            DrawGraphic(cx,cy-122);
        }

    }
}
