script_enemy_main {
    let time = 0;
    let phase = 1;
    let rate = 10;
    let kaku = 40;
    let score = 5000;
    let layer = 0;
    let bairitu = 1;
    let lv = 0;
    let angle = GetAngle();
    let rank = GetSpeed();
    let arg = GetArgument();
    let ex = GetCommonData("ex");
    let mapx = GetX();
    let mapy = GetY();
    let imgEnemy = GetCurrentScriptDirectory~"img\hunebig1.png";
    let tama = GetCurrentScriptDirectory~"tama.txt";
    let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
    let se9 = GetCurrentScriptDirectory~"wav\se9.wav";
    @Initialize(){
        SetLife( 550 );
        SetInvincibility( 60 );
        LoadGraphic( imgEnemy );
        LoadUserShotData( tama );
        SetX(mapx-GetCommonData("bgx"));
        SetY(GetCommonData("bgy")-mapy);
        setmove(angle,arg);
        Tshot1;
        Tgazou(1,1,408,240);
        Tgazouex(408, 0, 600, 180);
    }
    @MainLoop {
        if(phase==1&&GetLife<=100){
           phase-=1;
           if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, 224, 240, 600);}
           PlaySE(se9);
           Tdeath(16,70,2,0);
        }
        if(GetX-60<12||GetX-60>436||GetY<140){
           SetInvincibility( 5 );
        }
        if(time>1500){VanishEnemy;}
        if(phase>=1){SetCollisionA(GetX-60, GetY-54, 75);}
        SetX(mapx-GetCommonData("bgx"));
        SetY(GetCommonData("bgy")-mapy);
        if(GetCommonData("kakusei")>0){lv=1}
        else{lv=0}
        time++;
        yield;
    }
    @Finalize() {
    }
    @DrawLoop {
    }

    task Tshot1{
        yield;
        wait(30);
        let c=1.7;
        if(GetAngle>180){c=-1.7}
        let b=0;
        loop{
           if(GetY<400){
              SetShotDirectionType(ABSOLUTE);
              let a=0;
              loop(40){
                 if(phase<=0){return;}
                 CreateShotFromScript( "shot1",GetX()-25, GetY()-50, 2.7, a*9-b*c, 0, 13);
                 if(ex==1){
                    CreateShotFromScript( "shot1",GetX()-25, GetY()-50, 3.7, a*9-b*c, 0, 13);
                 }
                 a++;
              }
           }
           wait(25-lv*17);
           b++;
        }
    }

   task setmove(a,t) {
      loop(t) {
         mapx+=cos(a)*0.6;mapy-=sin(a)*0.6;
         yield;
      }
   }
   task Tgazou(x1,y1,x2,y2)
   {
      let system = GetCurrentScriptDirectory~"img\system.png";
      let objenemy = Obj_Create(OBJ_EFFECT);//エフェクトオブジェクトを作成
      ObjEffect_SetTexture(objenemy, imgEnemy);//なんらかのテクスチャを設定
      ObjEffect_SetPrimitiveType(objenemy, PRIMITIVE_TRIANGLESTRIP);//プリミティブタイプを設定
      ObjEffect_CreateVertex(objenemy, 4);//頂点を4個つくる
      ObjEffect_SetLayer(objenemy,layer);
		
      //四角形状に各頂点の座標を設定
      ObjEffect_SetVertexXY(objenemy, 0, -(x2-x1)*bairitu/2, -(y2-y1)*bairitu/2);
      ObjEffect_SetVertexXY(objenemy, 1, -(x2-x1)*bairitu/2,  (y2-y1)*bairitu/2);
      ObjEffect_SetVertexXY(objenemy, 2,  (x2-x1)*bairitu/2, -(y2-y1)*bairitu/2);
      ObjEffect_SetVertexXY(objenemy, 3,  (x2-x1)*bairitu/2,  (y2-y1)*bairitu/2);
		
      //四角形状に各頂点のUV値を設定。(0,0)-(10,10)の部分。
      ObjEffect_SetVertexUV(objenemy, 0, x1, y1);
      ObjEffect_SetVertexUV(objenemy, 1, x1, y2);
      ObjEffect_SetVertexUV(objenemy, 2, x2, y1);
      ObjEffect_SetVertexUV(objenemy, 3, x2, y2);

      Obj_SetPosition(objenemy, GetX, GetY);
   
		
      loop{
         ObjEffect_SetVertexXY(objenemy, 0, -(x2-x1)*bairitu/2, -(y2-y1)*bairitu/2);
         ObjEffect_SetVertexXY(objenemy, 1, -(x2-x1)*bairitu/2,  (y2-y1)*bairitu/2);
         ObjEffect_SetVertexXY(objenemy, 2,  (x2-x1)*bairitu/2, -(y2-y1)*bairitu/2);
         ObjEffect_SetVertexXY(objenemy, 3,  (x2-x1)*bairitu/2,  (y2-y1)*bairitu/2);
         Obj_SetX(objenemy,GetX);
         Obj_SetY(objenemy,GetY);
         yield;
      }
      Obj_Delete(objenemy);
   }
   task Tgazouex(x1,y1,x2,y2)
   {
      let system = GetCurrentScriptDirectory~"img\system.png";
      let objenemy = Obj_Create(OBJ_EFFECT);//エフェクトオブジェクトを作成
      ObjEffect_SetTexture(objenemy, imgEnemy);//なんらかのテクスチャを設定
      ObjEffect_SetPrimitiveType(objenemy, PRIMITIVE_TRIANGLESTRIP);//プリミティブタイプを設定
      ObjEffect_CreateVertex(objenemy, 4);//頂点を4個つくる
      ObjEffect_SetLayer(objenemy,1);
		
      //四角形状に各頂点の座標を設定
      ObjEffect_SetVertexXY(objenemy, 0, -(x2-x1)*bairitu/2, -(y2-y1)*bairitu/2);
      ObjEffect_SetVertexXY(objenemy, 1, -(x2-x1)*bairitu/2,  (y2-y1)*bairitu/2);
      ObjEffect_SetVertexXY(objenemy, 2,  (x2-x1)*bairitu/2, -(y2-y1)*bairitu/2);
      ObjEffect_SetVertexXY(objenemy, 3,  (x2-x1)*bairitu/2,  (y2-y1)*bairitu/2);
		
      //四角形状に各頂点のUV値を設定。(0,0)-(10,10)の部分。
      ObjEffect_SetVertexUV(objenemy, 0, x1, y1);
      ObjEffect_SetVertexUV(objenemy, 1, x1, y2);
      ObjEffect_SetVertexUV(objenemy, 2, x2, y1);
      ObjEffect_SetVertexUV(objenemy, 3, x2, y2);

      Obj_SetPosition(objenemy, GetX()-60, GetY()-54);
   
		
   	while(phase>=1){
         ObjEffect_SetVertexXY(objenemy, 0, -(x2-x1)*bairitu/2, -(y2-y1)*bairitu/2);
         ObjEffect_SetVertexXY(objenemy, 1, -(x2-x1)*bairitu/2,  (y2-y1)*bairitu/2);
         ObjEffect_SetVertexXY(objenemy, 2,  (x2-x1)*bairitu/2, -(y2-y1)*bairitu/2);
         ObjEffect_SetVertexXY(objenemy, 3,  (x2-x1)*bairitu/2,  (y2-y1)*bairitu/2);
         Obj_SetX(objenemy,GetX-60);
         Obj_SetY(objenemy,GetY-54);
         yield;
      }
      Obj_Delete(objenemy);
   }



    #include_function".\efanction.txt"
}

#include_script".\escript.txt"