#東方弾幕風 #Title[魔鏡「光の道筋」] #Text[自作No.0] #ScriptVersion[2] script_enemy_main { let name = "魔鏡「光の道筋」"; let imgBoss = "script\img\ExRumia.png"; let maxLife = 300; let spartLife = maxLife/3; // 初期位置 let xIni = GetCenterX; let yIni = GetClipMinY + 128; // レーザー区切間隔 let intLaserX = (GetClipMaxX - GetClipMinX) / 3; let intLaserY = (GetClipMaxY - GetClipMinY - 128) / 10; @Initialize { CutIn(YOUMU, name, "", 0, 0, 0, 0); SetLife(300); SetTimer(60); SetScore(2500000); SetDamageRate(5, 5); LoadGraphic(imgBoss); SetTexture(imgBoss); setGraphicStop; TMain; } @MainLoop { SetCollisionA(GetX, GetY, 32); SetCollisionB(GetX, GetY, 16); yield; } @DrawLoop { DrawGraphic(GetX, GetY); } @Finalize { DeleteGraphic(imgBoss); } // メインタスク task TMain { let typeRed = RED11; let wShot1 = 32; yield; standBy; readyLaser; TStartLS; loop { move; wait(16); if(GetEnemyLife > spartLife){shot1(2, 8);}else{shot1(3, 8);} wait(wShot1); } } // 初期位置へ移動し、攻撃開始 sub standBy { let wIni = 120; SetMovePosition02(xIni, yIni, wIni); setGraphicMove; SetInvincibility(wIni); wait(wIni); setGraphicPose; } // 1重の円状 n-way 弾 // v : 速度 // type : 弾のタイプ function shot1(v, w) { let type; let i = 0; loop(5){ let dir = GetAngleToPlayer; if(i != 5 - 1){type = RED11;}else{type = RED03;} nwayCircle(20, v + 0.15 * i, dir, type); wait(w); i++; } } task TStartLS { loop { if(GetEnemyLife > spartLife){ TShootLS(1, BLUE11); wait(16); }else{ TShootLS(1, BLUE11); wait(8); TShootLS(2, AQUA31); wait(8); } yield; } } task TShootLS (v, type) { let dirType = rand_int(0, 3); let x = GetClipMinX + intLaserX + rand(0, intLaserX); let y = GetClipMinY + 128 + intLaserY * 3 + rand(0, intLaserY * 4); alternative (dirType) case(0){x = GetClipMinX;} case(1){y = GetClipMinY + 128;} case(2){x = GetClipMaxX;} case(3){y = GetClipMaxY;} yield; TCreateLS(x, y, v, dirType, type); } task TCreateLS(x, y, v, dirType, type) { let obj = Obj_Create(OBJ_SHOT); Obj_SetX(obj, x); Obj_SetY(obj, y); Obj_SetAngle(obj, 90 * dirType); ObjShot_SetGraphic(obj, type); Obj_SetSpeed(obj, v); loop{ if(Obj_BeDeleted(obj)) {break;} if(changeLS(Obj_GetX(obj) , Obj_GetY(obj) , dirType)) {Obj_SetSpeed(obj, v * 16);} yield; } } function changeLS(x , y, dirType) { result = false; alternative(dirType) case(0){if(x >= GetClipMinX + intLaserX ) {result = true;}} case(1){if(y >= GetClipMinY + 128 + intLaserY * 3) {result = true;}} case(2){if(x <= GetClipMaxX - intLaserX ) {result = true;}} case(3){if(y <= GetClipMaxY - intLaserY * 3 ) {result = true;}} } sub readyLaser { let spanX = (GetClipMaxX - GetClipMinX) / 30; let spanY = (GetClipMaxY - GetClipMinY) / 30; let v; let vlen; CreateLaserA(0, GetClipMinX + 2, GetClipMinY + 2, 0, 10, YELLOW01, 0); CreateLaserA(1, GetClipMaxX - 2, GetClipMinY + 2, 0, 10, YELLOW01, 0); CreateLaserA(2, GetClipMaxX - 2, GetClipMaxY - 2, 0, 10, YELLOW01, 0); CreateLaserA(3, GetClipMinX + 2, GetClipMaxY - 2, 0, 10, YELLOW01, 0); let id = 0; loop(4){ if(id == 0 || id == 2){vlen = spanX;}else{vlen = spanY;} alternative(id) case(1, 3){v = intLaserX / 30;} case(0){v = (intLaserY * 3 + 128) / 30;} case(2){v = intLaserY * 3 / 30;} SetLaserDataA(id, 0 , 90 * id, 0, vlen, 0, 0 ); SetLaserDataA(id, 30 , 90 * id, 0, 0 , v, 90 * (id + 1)); SetLaserDataA(id, 30 * 2 , 90 * id, 0, 0 , 0, 0 ); FireShot(id); id++; } } // 円状 n-way 弾 // way : way 数 // v : 速度 // dir : 基準とする方向 // type : 弾のタイプ function nwayCircle(way, v, dir, type) { let span = 360 / way; let angle = dir; loop(way) { CreateShot01(GetX, GetY, v, angle, type, 0); angle += span; } } // 移動 sub move { let wMove = 40; moveToPlayer(rand(40, 80), rand(-40, 40), wMove, GetClipMinX + intLaserX, GetClipMinY + 32, GetClipMaxX - intLaserX, GetClipMinY + 128); setGraphicMove; wait(wMove); setGraphicStop; } // なるべくプレイヤーの方向に移動 // xMove : x 方向の移動量(正の数) // yAdd : y 方向の移動量 // frame : 移動に要するフレーム数 // left : 以下、可動範囲 // top : // right : // bottom : function moveToPlayer(xMove, yAdd, frame, left, top, right, bottom) { let x; let y; if(GetPlayerX < GetX) { // プレイヤーより右に敵がいれば、敵は左に動きます。 x = GetX - xMove; // 但し、敵が可動領域の左端よりも左にいくようなら、右に動きます。 if(x < left) { x = GetX + xMove; } } else { // さもなくば、敵は右に動きます。 x = GetX + xMove; // 但し、敵が可動領域の右端よりも右にいくようなら、左に動きます。 if(right < x) { x = GetX - xMove; } } // 可動領域の外に行く場合は、端っこで止めます。 y = GetY + yAdd; if(y < top) { y = top; } else if(bottom < y) { y = bottom; } SetMovePosition02(x, y, frame); } // グラフィックの設定 sub setGraphicStop { SetGraphicRect( 0, 0, 64, 64); } sub setGraphicPose { SetGraphicRect( 64, 0, 128, 64); } sub setGraphicLeft { SetGraphicRect(128, 0, 192, 64); } sub setGraphicRight { SetGraphicRect(192, 0, 256, 64); } sub setGraphicMove { if(GetSpeedX < 0) { setGraphicLeft; } else { setGraphicRight; } } // w フレームだけ待つ function wait(w) { loop(w) { yield; } } }