script_enemy_main {
    let phase = 1;
    let angle = 90;
    let time = 0;
    let rate = 0;
    let kaku = 0;
    let layer = 3;
    let bairitu = 1.3;
    let score = 0;
    let rank = GetSpeed;
    let rankd = 0;
    let mapx = GetX();
    let mapy = GetY();
    let arg = GetArgument();
    let imgEnemy = GetCurrentScriptDirectory~"img\item.png";
    let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
    let se3 = GetCurrentScriptDirectory~"wav\se3.wav";
    let ex = GetCommonData("ex");
    @Initialize(){
        LoadGraphic( imgEnemy );
        SetLife( 10 );
        SetSpeed(1);
        SetX(mapx-GetCommonData("bgx"));
        SetY(GetCommonData("bgy")-mapy);
        Tgazou( 0, 32, 32, 64)
    }
    @MainLoop {
        if(((GetX-GetPlayerX)^2+(GetY-GetPlayerY)^2)<50^2){
           PlaySE("se1UP.wav");
           ExtendPlayer(1);
           VanishEnemy;
        }
        SetX(mapx-GetCommonData("bgx"));
        SetY(GetCommonData("bgy")-mapy);
        yield;
        time++;
    }
    @Finalize() {
    }
    @DrawLoop {
	/*SetTexture( imgEnemy );
        SetGraphicRect( 0, 0, 32, 32 );
        SetGraphicScale(1.3,1.3);
	DrawGraphic( GetX(), GetY() );*/
    }

    task Tmove {
        SetMovePosition02(224, 200, 60);
        wait(60);
        let a=2;
        loop(9){
           SetMovePosition02(GetX+cos(a*90-90)*trunc(a/2)*55, GetY+sin(a*90-90)*trunc(a/2)*55, trunc(a/2)*40);
           wait(trunc(a/2)*40);
           a++;
        }
        SetMovePosition02(GetX+cos(a*90-90)*trunc(a/2+2)*55, GetY+sin(a*90-90)*trunc(a/2+2)*55, trunc(a/2+2)*40);
        wait(trunc(a/2+2)*40);
        VanishEnemy;
    }

   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);
   
		
      while(phase>0){
         Obj_SetX(objenemy,GetX);
         Obj_SetY(objenemy,GetY);
         yield;
      }
      Obj_Delete(objenemy);
   }

   #include_function".\efanction.txt"
}

#include_script".\escript.txt"