script_enemy_main {
    let time = 0;
    let phase = 1;
    let rate = 7;
    let kaku = 40;
    let score = 1600;
    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\tankbig1.png";
    let tama = GetCurrentScriptDirectory~"tama.txt";
    let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
    let se9 = GetCurrentScriptDirectory~"wav\se9.wav";
    @Initialize(){
		SetLife( 1300 );
		SetInvincibility( 100 );
		LoadGraphic( imgEnemy );
		LoadUserShotData( tama );
		SetX(mapx-GetCommonData("bgx"));
		SetY(GetCommonData("bgy")-mapy);
		Tmove;
		Tshot1;
		Tgazou(1, 1, 144, 144);
		layer = 0;
    }
    @MainLoop {
        if(phase==1&&GetLife<=100){
           phase-=1;
           if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, 224, 240, 600);}
           PlaySE(se9);
           Tdeath(14,64,2,1);
        }
        if(phase>=1){SetCollisionA(GetX(), GetY(), 60);}
        SetX(mapx-GetCommonData("bgx"));
        SetY(GetCommonData("bgy")-mapy);
        if(GetCommonData("kakusei")>0){lv=1}
        else{lv=0}
        time++;
        yield;
    }
    @Finalize() {
    }
    @DrawLoop {
    }

	task Tshot1 {
		wait(100);
		let a=0;
		loop{
			let b=0;
			loop(5){
				if(phase<1){return;}
				let c=0;
				loop(1+ex){
					SetShotDirectionType( ABSOLUTE );
					CreateShotFromScript( "shot1",GetX(), GetY(), 2.4-b*0.02+ex, 186-b*1.6-a*23-c*180, 0, 07);
					CreateShotFromScript( "shot1",GetX(), GetY(), 2.4-b*0.02+ex, -6+b*1.6+a*23+c*180, 0, 07);
					c++;
				}
				b++;
			}
			wait(4-lv*2);
			if(GetY>350){return;}
			a++;
		}
	}
	task Tmove{
		angle=90;
		angle = 90;
		setmove(angle,100);
		wait(100);
		wait(50);
		angle = 270;
		setmove(angle,240);
		wait(240);
		wait(1400);
		VanishEnemy;
	}

   task setmove(a,t) {
      loop(t) {
         mapx+=cos(a)*0.8;mapy-=sin(a)*0.8;
         yield;
      }
   }



let layer = 1;
let bairitu = 1;

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

    #include_function".\efanction.txt"
}

#include_script".\escript.txt"