

  let csd = GetCurrentScriptDirectory;
  let cx=GetCenterX();
  let cy=GetCenterY();
  let minx=GetClipMinX();
  let miny=GetClipMinY();
  let maxx=GetClipMaxX();
  let maxy=GetClipMaxY();
  let timecounter1 = csd~ "se\timecounter01.wav";         LoadSE(timecounter1);  
  let timecounter2 = csd~ "se\timecounter02.wav";         LoadSE(timecounter2);  
  let seshot1 = csd~ "se\enemyshot01.wav"; LoadSE(seshot1);
  let sevanish = csd~ "se\BossVanish.wav"; LoadSE(sevanish);
  let redeye = csd~ "se\redeyes.wav"; LoadSE(redeye);
  let SpellBack = csd~".\img\ReisenSpellBack.png"; LoadGraphic(SpellBack);
  let RedEyes = csd~".\img\UFG.png"; LoadGraphic(RedEyes);
  SetRateScoreSystemEnable(false);
  let sgrnum = 0;
 Graph;
 let phantom = false; 

    task Count{
        while(GetTimer > 10){yield;}
     loop(5){
      PlaySE(timecounter1); 
        loop(60){yield;}
       }
       loop(5){
          PlaySE(timecounter2); 
        loop(60){yield;}
       }
    }

  task Graph{
  let second = 0;
  loop{
   alternative(sgrnum)
    case(0){
     alternative(second)
         case(0,1,2,3,4,5,6,7,8,9,10,11){sgr(0,0); second++;}
         case(12,13,14,15,16,17,18,19,20,21,22,23){sgr(1,0); second++;}
         case(24,25,26,27,28,29,30,31,32,33,34,35){sgr(0,1); second++;}
         case(36,37,38,39,40,41,42,43,44,45,46,47){sgr(0,2); second++;}
         case(48,49,50,51,52,53,54,55,56,57,58,59){sgr(1,0); second++;}
         others{second = 0;}
      }   
    case(1){
       alternative(second)
         case(0,1,2,3,4,5,6,7,8,9){sgr(2,1); second = 0;}
         case(10){sgr(2,1); second = 0;}
        others{second = 10;}
     }
      case(2){
       alternative(second)
         case(0,1,2,3,4,5,6,7,8,9){sgr(2,2); second = 0;}
         case(10){sgr(2,3); second = 0;}
        others{second = 10;}
     }
     case(3){
     alternative(second)
if(0<=second && second <= 29){sgr(4,0); second++;}
  else if(30<=second && second <= 59){sgr(4,1); second++;}
  else if(60<=second && second <= 69){sgr(5,0); second++;} 
  else if(70<=second && second <= 90){sgr(5,1); second++;}   
         else{second = 90;}
      } 
   case(4){
  sgr(5,3); second=0;  
      } 
  case(5){
  if((0<=second && second <= 11) || (48<=second && second <= 58)){sgr(3,0); second++;}
  else if((12<=second && second <= 23) || (36<=second && second <= 47)){sgr(3,1); second++;}
  else if(24<=second && second <= 35){sgr(3,2); second++;}   
         else{second = 0;}
     }
   wait(1);
    }
  }


 task SpellBackGround(size){
           let c= Obj_Create(OBJ_EFFECT);
             Obj_SetX(c,cx);
             Obj_SetY(c,cy);
             Obj_SetAngle(c,0);
             ObjEffect_SetAngle(c,0,0,0);
             ObjEffect_SetTexture(c,SpellBack);
             ObjEffect_SetRenderState(c,ADD);
             ObjEffect_SetPrimitiveType(c,PRIMITIVE_TRIANGLEFAN);
             ObjEffect_SetLayer(c,0);
             ObjEffect_CreateVertex(c,62);
             ObjEffect_SetVertexXY(c,0,0,0);
             ObjEffect_SetVertexUV(c,0,320,240);
             ObjEffect_SetVertexColor(c,0,64,255,255,255);
             ObjEffect_SetScale(c,size/10,size/10);

            ascent(let i in 0..61){
                ObjEffect_SetVertexXY(c,i+1,cos(i*6)*20,sin(i*6)*20);
                ObjEffect_SetVertexUV(c,i+1,cos(i*6)*200+320,sin(i*6)*200+240);
                ObjEffect_SetVertexColor(c,i+1,64,255,255,255);
            }
      Set; 
     task Set{
   let i = 0;
         while(!Obj_BeDeleted(c)){
            ObjEffect_SetAngle(c,0,0,i/10);
        i++;
            yield;
           }
         }
    }

 task SpellBackPhantom(size){
           let c= Obj_Create(OBJ_EFFECT);
             Obj_SetX(c,cx);
             Obj_SetY(c,cy);
             Obj_SetAngle(c,0);
             ObjEffect_SetAngle(c,0,0,0);
             ObjEffect_SetTexture(c,SpellBack);
             ObjEffect_SetRenderState(c,ADD);
             ObjEffect_SetPrimitiveType(c,PRIMITIVE_TRIANGLEFAN);
             ObjEffect_SetLayer(c,1);
             ObjEffect_CreateVertex(c,62);
             ObjEffect_SetVertexXY(c,0,0,0);
             ObjEffect_SetVertexUV(c,0,320,240);
             ObjEffect_SetVertexColor(c,0,64,255,0,0);
             ObjEffect_SetScale(c,size/10,size/10);

            ascent(let i in 0..61){
                ObjEffect_SetVertexXY(c,i+1,cos(i*6)*20,sin(i*6)*20);
                ObjEffect_SetVertexUV(c,i+1,cos(i*6)*200+320,sin(i*6)*200+240);
                ObjEffect_SetVertexColor(c,i+1,64,255,0,0);
            }
    Del;
  task Del{
   while(phantom){
       wait(1);
         }
     Obj_Delete(c);
             }
    }


task RedEye(size,x,y,i){
           let c= Obj_Create(OBJ_EFFECT);
             Obj_SetX(c,x);
             Obj_SetY(c,y);
             Obj_SetAngle(c,2);
             ObjEffect_SetAngle(c,0,0,0);
             ObjEffect_SetTexture(c,RedEyes);
             ObjEffect_SetRenderState(c,ALPHA);
             ObjEffect_SetPrimitiveType(c,PRIMITIVE_TRIANGLEFAN);
             ObjEffect_SetLayer(c,1);
             ObjEffect_CreateVertex(c,62);
             ObjEffect_SetVertexXY(c,0,0,0);
             ObjEffect_SetVertexUV(c,0,64,64);
             ObjEffect_SetVertexColor(c,0,255,255,0,0);
             ObjEffect_SetScale(c,size/10,size/10);

            ascent(let i in 0..61){
                ObjEffect_SetVertexXY(c,i+1,cos(i*6)*20,sin(i*6)*20);
                ObjEffect_SetVertexUV(c,i+1,cos(i*6)*64+64,sin(i*6)*64+64);
                ObjEffect_SetVertexColor(c,i+1,255,255,0,0);
            }
      Set; 
     task Set{
         while(!Obj_BeDeleted(c)){
           ObjEffect_SetAngle(c,0,0,i); 
  ObjEffect_SetScale(c,size/10,size/10/2);
     size = 0.9995*size;
           wait(1);
           }
         }
   Del;
  task Del{
   while(phantom){
       wait(1);
         }
     Obj_Delete(c);
             }
    }

   task P(x,y,v,angle,color,color2,delay,dangle,pv,prad,v2,ff){
        let p = Obj_Create(OBJ_SHOT);
         Obj_SetX(p,x);
         Obj_SetY(p,y);
         Obj_SetSpeed(p,v);
         Obj_SetAngle(p,angle);
         ObjShot_SetGraphic(p,color);
         ObjShot_SetDelay(p,delay);
         Obj_SetAutoDelete(p,false);
         ObjShot_SetBombResist(p,false);
   Obj_SetCollisionToPlayer(p,true);
   wait(delay);
    Idle;
    task Idle{
    while(!phantom){Obj_SetAngle(p,Obj_GetAngle(p)+dangle); wait(1);}
    ObjShot_SetGraphic(p,color2);
   Obj_SetCollisionToPlayer(p,false);
    Obj_SetSpeed(p,0);
    while(phantom){
   Obj_SetX(p,Obj_GetX(p)+pv*cos(prad));
   Obj_SetY(p,Obj_GetY(p)+pv*sin(prad));
     wait(1);
    }
   if(GetTimer >= 18){
  CreateShotA(0,Obj_GetX(p),Obj_GetY(p),0);
  SetShotDataA(0,0,0.5,Obj_GetAngle(p),0,0,10,color);
  SetShotDataA(0,ff/2,NULL,Obj_GetAngle(p),0,-0.5/60,0,color-56-24);
  SetShotDataA(0,ff/2+60,NULL,Obj_GetAngle(p),0,0,0,color-56);
  SetShotDataA(0,ff,NULL,Obj_GetAngle(p),0,0.1,10,color-40);
  FireShot(0);
       }
  else if(GetTimer < 18){
  CreateShotA(0,Obj_GetX(p),Obj_GetY(p),0);
  SetShotDataA(0,0,0.5,Obj_GetAngle(p),0,0,10,color);
  SetShotDataA(0,ff/2,NULL,Obj_GetAngle(p),0,-0.5/60,0,color-56-24);
  SetShotDataA(0,ff/2+60,NULL,Obj_GetAngle(p),0,0,0,color-56);
  SetShotDataA(0,ff/2+120,0,Obj_GetAngle(p),0,-1/80,-10,color-40);
  FireShot(0);
   CreateShotA(1,Obj_GetX(p),Obj_GetY(p),0);
  SetShotDataA(1,0,0.5,Obj_GetAngle(p),0,0,10,color);
  SetShotDataA(1,ff/2,NULL,Obj_GetAngle(p),0,-0.5/60,0,color-56-24);
  SetShotDataA(1,ff/2+60,NULL,Obj_GetAngle(p),0,0,0,color-56);
  SetShotDataA(1,ff/2+120,0,Obj_GetAngle(p),0,0.1,10,color-40);
  FireShot(1);
       }
   Obj_Delete(p);
       }
   }

 task P2(x,y,v,angle,color,color2,delay,dangle,pv,prad,v2,ff){
        let p = Obj_Create(OBJ_SHOT);
         Obj_SetX(p,x);
         Obj_SetY(p,y);
         Obj_SetSpeed(p,v);
         Obj_SetAngle(p,angle);
         ObjShot_SetGraphic(p,color);
         ObjShot_SetDelay(p,delay);
         Obj_SetAutoDelete(p,true);
         ObjShot_SetBombResist(p,false);
   Obj_SetCollisionToPlayer(p,true);
   wait(delay);
    Idle;
    task Idle{
    while(!phantom){wait(1);}
   CreateShot02(Obj_GetX(p),Obj_GetY(p),0,Obj_GetAngle(p)+180,0.1,10,color2,0);
   Obj_Delete(p);
       }
   }

/*task L(x,y,angle,length,width,color,delay){
              let l = Obj_Create(OBJ_LASER);
              Obj_SetX(l,x);
              Obj_SetY(l,y);
              Obj_SetAngle(l,angle);
              Obj_SetAutoDelete(l,false);
              ObjShot_SetGraphic(l,color);
              ObjShot_SetDelay(l,delay);
              Obj_SetCollisionToObject(l,true);
              Obj_SetCollisionToPlayer(l,true);
              ObjLaser_SetLength(l,length);
              ObjLaser_SetWidth(l,width);
              ObjLaser_SetSource(l,false);
    wait(delay);
    Obj_Delete(l);
     }  */
