#東方弾幕風 #Title[test] #Text[test] #ScriptVersion[2] script_enemy_main { let imgBoss = "script\img\ExRumia.png"; @Initialize { SetLife(2000); SetDamageRate(5, 5); LoadGraphic(imgBoss); SetTexture(imgBoss); setGraphicStop; TASKMAIN; } @MainLoop { SetCollisionA(GetX, GetY, 32); SetCollisionB(GetX, GetY, 16); yield; } @DrawLoop {DrawGraphic(GetX, GetY);} @Finalize {DeleteGraphic(imgBoss);} // メインタスク task TASKMAIN { yield; standBy; SetDamageRate(40, 30); loop { shot; wait(9999); } } // 初期位置へ移動 sub standBy { let wIni = 120; let xIni = 100; let yIni = 100; SetMovePosition02(xIni, yIni, wIni); setGraphicMove; SetInvincibility(wIni); wait(wIni); } sub shot { loop(1) { let id = 0; //ID // 設置型レーザーを作製する関数。 // 1) ID:自由に指定できる数値。このあとにSetLaserDataA、FireShot、AddShot関数に同じものを使う。 // 2) x(レーザーを設置する絶対x座標) // 3) y(レーザーを設置する絶対y座標) // 4) レーザーの長さ // 5) レーザーの幅 // 6) 画像 // 7) 遅延時間(レーザーが実体化するまでの時間) CreateLaserA(id,100,100,100,10,RED01,10); // 1) ID:CreateLaserAで指定したID。 // 2) 軌道を変化させるフレーム(FireShot後の経過フレーム) // 3) 角度(NULLを指定することで現在の値を引き継ぐ) // 4) 角速度(1フレームあたりの角度変化量) // 5) 長さの変化量 // 6) 設置点移動速度(1フレームあたりの設置点移動量) // 7) 設置点移動角度 SetLaserDataA(id, 10, NULL, 0, 0, 0, 0); FireShot(id); } } // なるべくプレイヤーの方向に移動 // 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; } } }