public override IEnumerable <bool> E_Task() { DDPicture picture = Ground.I.Picture.Title; double slideRate = 0.0; double leaveRate = 0.0; double z = 1.0; for (; ;) { DDUtils.Approach(ref slideRate, 1.0, 0.9999); DDUtils.Approach(ref leaveRate, this.TopMenuLeaved ? 1.0 : 0.0, 0.95); DDUtils.Approach(ref z, this.TopMenuLeaved ? 1.02 : 1.0, 0.9); D4Rect drawRect = DDUtils.AdjustRectExterior( picture.GetSize().ToD2Size(), new D4Rect(0, 0, DDConsts.Screen_W, DDConsts.Screen_H), slideRate ); DDDraw.DrawBeginRect(Ground.I.Picture.Title, drawRect.L, drawRect.T, drawRect.W, drawRect.H); DDDraw.DrawZoom(z); DDDraw.DrawEnd(); if (0.01 < leaveRate) { ぼかし効果.Perform(leaveRate); DDCurtain.DrawCurtain(-0.6 * leaveRate); } yield return(true); } }
/// <summary> /// サイズを(アスペクト比を維持して)矩形領域いっぱいに広げる。 /// </summary> /// <param name="size">サイズ</param> /// <param name="rect">矩形領域</param> /// <param name="interior">矩形領域の内側に張り付く場合の出力先</param> /// <param name="exterior">矩形領域の外側に張り付く場合の出力先</param> public static void AdjustRect(D2Size size, D4Rect rect, out D4Rect interior, out D4Rect exterior) { double w_h = (rect.H * size.W) / size.H; // 高さを基準にした幅 double h_w = (rect.W * size.H) / size.W; // 幅を基準にした高さ D4Rect rect1; D4Rect rect2; rect1.L = rect.L + (rect.W - w_h) / 2.0; rect1.T = rect.T; rect1.W = w_h; rect1.H = rect.H; rect2.L = rect.L; rect2.T = rect.T + (rect.H - h_w) / 2.0; rect2.W = rect.W; rect2.H = h_w; if (w_h < rect.W) { interior = rect1; exterior = rect2; } else { interior = rect2; exterior = rect1; } }
public static DDCrash Rect(D4Rect rect) { return(new DDCrash() { Kind = Kind_e.RECT, Rect = rect, }); }
public static D4Rect Slide(D4Rect start, D4Rect end, double rate) { return(new D4Rect( Slide(start.L, end.L, rate), Slide(start.T, end.T, rate), Slide(start.W, end.W, rate), Slide(start.H, end.H, rate) )); }
public static D4Rect AdjustRectInterior(D2Size size, D4Rect rect) { D4Rect interior; D4Rect exterior; AdjustRect(size, rect, out interior, out exterior); return(interior); }
private static D4Rect Prv_AdjustRectExterior(D2Size size, D4Rect rect) { D4Rect interior; D4Rect exterior; AdjustRect(size, rect, out interior, out exterior); return(exterior); }
private void Test01_a2(D2Size size, D4Rect rect, string destName, D4Rect dest) { ProcMain.WriteLog(string.Format("({0}) -> ({1}) {2} -> {3}" , string.Join(", ", size.W, size.H) , string.Join(", ", rect.L, rect.T, rect.W, rect.H) , destName , string.Join(", ", dest.L, dest.T, dest.W, dest.H) )); }
public static D4Rect AdjustRectExterior(D2Size size, D4Rect rect, double slideRate = 0.5) { D4Rect interior; D4Rect exterior; AdjustRect(size, rect, out interior, out exterior, slideRate); return(exterior); }
private void Test01_a(D2Size size, D4Rect rect) { D4Rect interior; D4Rect exterior; DDUtils.AdjustRect(size, rect, out interior, out exterior); Test01_a2(size, rect, "INTERIOR", interior); Test01_a2(size, rect, "EXTERIOR", exterior); }
protected override IEnumerable <bool> E_Draw() { double x1; double x2; if (this.FacingLeft) { x1 = DDGround.ICamera.X; x2 = this.X; } else { x1 = this.X; x2 = DDGround.ICamera.X + DDConsts.Screen_W; } double y1 = this.Y - 2.0; double y2 = this.Y + 2.0; if (x2 < x1 + 2.0) { goto endFunc; } DDDraw.SetAlpha(0.2 + 0.1 * Math.Sin(DDEngine.ProcFrame / 2.0)); DDDraw.SetBright(0.0, 1.0, 1.0); DDDraw.DrawRect_LTRB( Ground.I.Picture.WhiteBox, x1 - DDGround.ICamera.X, y1 - DDGround.ICamera.Y, x2 - DDGround.ICamera.X, y2 - DDGround.ICamera.Y ); DDDraw.Reset(); if (DDEngine.ProcFrame % 5 == 0) // 間隔適当 { this.Crash = DDCrashUtils.Rect(D4Rect.LTRB(x1, y1, x2, y2)); } // 1回だけ true を返して1フレームだけ生存する必要がある。 // -- 当たり判定時に、自弾リストに this が無いと this.Crash は参照されない。 // yield return(true); // 1フレームで消滅する。 endFunc: ; //yield break; }
/// <summary> /// サイズを(アスペクト比を維持して)矩形領域(入力)の外側に張り付く矩形領域(出力)を生成する。 /// スライドレート: /// -- 0.0 ~ 1.0 /// -- 0.0 == 矩形領域(出力)を最も左・上側に寄せる == 矩形領域(出力)の右・下側と矩形領域(入力)の右・下側が重なる /// -- 0.5 == 中央 /// -- 1.0 == 矩形領域(出力)を最も右・下側に寄せる == 矩形領域(出力)の左・上側と矩形領域(入力)の左・上側が重なる /// </summary> /// <param name="size">サイズ</param> /// <param name="rect">矩形領域(入力)</param> /// <param name="xRate">スライドレート(X_方向)</param> /// <param name="yRate">スライドレート(Y_方向)</param> /// <param name="extraZoom">倍率(外側に張り付くサイズからの倍率)</param> /// <returns>矩形領域(出力)</returns> public static D4Rect AdjustRectExterior(D2Size size, D4Rect rect, double xRate = 0.5, double yRate = 0.5, double extraZoom = 1.0) { D4Rect exterior = Prv_AdjustRectExterior(size, rect); exterior.W *= extraZoom; exterior.H *= extraZoom; double rangeX = exterior.W - rect.W; double rangeY = exterior.H - rect.H; exterior.L = rect.L + rangeX * (xRate - 1.0); exterior.T = rect.T + rangeY * (yRate - 1.0); return(exterior); }
private static bool TitleDDStartConfirm() { bool ret = false; P_TitleBackWDest = DDConsts.Screen_W; DDEngine.FreezeInput(); for (; ;) { DDMouse.UpdatePos(); if (DDMouse.L.GetInput() == 1) { int x = DDMouse.X; int y = DDMouse.Y; if (DDUtils.IsOut(new D2Point(x, y), D4Rect.LTRB(270, 280, 370, 320)) == false) // はい { ret = true; break; } else if (DDUtils.IsOut(new D2Point(x, y), D4Rect.LTRB(520, 280, 690, 320)) == false) // いいえ { break; } } DrawWall(); DrawTitleBack(); PrintByFont.SetPrint(); PrintByFont.Print(""); PrintByFont.Print(""); PrintByFont.Print(""); PrintByFont.Print(""); PrintByFont.Print(""); PrintByFont.Print(" セーブデータを消去します。よろしいですか?"); PrintByFont.Print(""); PrintByFont.Print(" は い い い え"); DDEngine.EachFrame(); } return(ret); }
protected override IEnumerable <bool> E_Draw() { RippleEffect.Add_波紋(this.X, this.Y, 60); RippleEffect.Add_波紋(this.X, this.Y, 120); RippleEffect.Add_波紋(this.X, this.Y, 180); RippleEffect.Add_波紋(this.X, this.Y, 360); for (int frame = 0; frame < GameConsts.PLAYER_BOMB_FRAME_MAX + 60; frame++) { this.Crash = DDCrashUtils.Rect(D4Rect.LTRB( 0, 0, GameConsts.FIELD_W, GameConsts.FIELD_H )); yield return(true); } }
private static void TitleConfigResetPlayData() { DDEngine.FreezeInput(); for (; ;) { DDMouse.UpdatePos(); if (DDMouse.L.GetInput() == 1) { int x = DDMouse.X; int y = DDMouse.Y; if (DDUtils.IsOut(new D2Point(x, y), D4Rect.LTRB(270, 280, 370, 320)) == false) // はい { // TODO SE // TODO reset play data SaveData.HasSaveData = false; // セーブデータもリセットする必要あり。 break; } else if (DDUtils.IsOut(new D2Point(x, y), D4Rect.LTRB(520, 280, 690, 320)) == false) // いいえ { break; } } DrawWall(); DrawTitleBack(); PrintByFont.SetPrint(); PrintByFont.Print(""); PrintByFont.Print(""); PrintByFont.Print(""); PrintByFont.Print(""); PrintByFont.Print(""); PrintByFont.Print(" プレイデータを消去します。よろしいですか?"); PrintByFont.Print(""); PrintByFont.Print(" は い い い え"); DDEngine.EachFrame(); } }
private static void DrawLayer(D4Rect frontBaseRect, D4Rect behindBaseRect, int y) { DrawDungWall(Layout.GetWall(0, y, 8), frontBaseRect.Poly, y + 0.5); int x; for (x = 1; ; x++) { D4Rect frontRect = frontBaseRect; frontRect.L = frontBaseRect.L + x * frontBaseRect.W; if (DungeonDesign.DUNG_SCREEN_W <= frontRect.L) { break; } DrawDungWall(Layout.GetWall(x, y, 8), frontRect.Poly, y + 0.5); frontRect.L = frontBaseRect.L - x * frontBaseRect.W; DrawDungWall(Layout.GetWall(-x, y, 8), frontRect.Poly, y + 0.5); } for (x -= 2; 0 <= x; x--) { D4Rect frontRect = frontBaseRect; D4Rect behindRect = behindBaseRect; frontRect.L = frontBaseRect.L + x * frontBaseRect.W; behindRect.L = behindBaseRect.L + x * behindBaseRect.W; DrawDungWall(Layout.GetWall(x, y, 6), new P4Poly(frontRect.RT, behindRect.RT, behindRect.RB, frontRect.RB), y); frontRect.L = frontBaseRect.L - x * frontBaseRect.W; behindRect.L = behindBaseRect.L - x * behindBaseRect.W; DrawDungWall(Layout.GetWall(-x, y, 4), new P4Poly(behindRect.LT, frontRect.LT, frontRect.LB, behindRect.LB), y); } }
protected override IEnumerable <bool> E_Draw() { #if true foreach (DDScene scene in DDSceneUtils.Create(60)) { this.Crash = DDCrashUtils.Rect(D4Rect.LTRB( 0, DDUtils.AToBRate(GameConsts.FIELD_H - 30.0, -30.0, scene.Rate), GameConsts.FIELD_W, GameConsts.FIELD_H )); yield return(true); } #else // シンプル for (int c = 0; c < 10; c++) { this.Crash = DDCrashUtils.Rect(new D4Rect(0, 0, GameConsts.FIELD_W, GameConsts.FIELD_H)); yield return(true); } #endif }
/// <summary> /// 円1と矩形2が衝突しているか判定する。 /// </summary> /// <param name="pt1">円1の中心</param> /// <param name="r1">円1の半径</param> /// <param name="rect2">矩形2の座標</param> /// <returns>衝突しているか</returns> public static bool IsCrashed_Circle_Rect(D2Point pt1, double r1, D4Rect rect2) { if (pt1.X < rect2.L) // 左 { if (pt1.Y < rect2.T) // 左上 { return(IsCrashed_Circle_Point(pt1, r1, new D2Point(rect2.L, rect2.T))); } else if (rect2.B < pt1.Y) // 左下 { return(IsCrashed_Circle_Point(pt1, r1, new D2Point(rect2.L, rect2.B))); } else // 左中段 { return(rect2.L < pt1.X + r1); } } else if (rect2.R < pt1.X) // 右 { if (pt1.Y < rect2.T) // 右上 { return(IsCrashed_Circle_Point(pt1, r1, new D2Point(rect2.R, rect2.T))); } else if (rect2.B < pt1.Y) // 右下 { return(IsCrashed_Circle_Point(pt1, r1, new D2Point(rect2.R, rect2.B))); } else // 右中段 { return(pt1.X - r1 < rect2.R); } } else // 真上・真ん中・真下 { return(rect2.T - r1 < pt1.Y && pt1.Y < rect2.B + r1); } }
private DDCrash GetTabTitleCrash_拡張設定() { return(DDCrashUtils.Rect(D4Rect.LTRB(550, 50, 1050, 150))); }
private static void TitleConfig() { P_TitleBackWDest = DDConsts.Screen_W; DDEngine.FreezeInput(); for (; ;) { DDMouse.UpdatePos(); if (DDUtils.IsPound(DDMouse.L.GetInput())) { int x = DDMouse.X; int y = DDMouse.Y; if (DDUtils.IsOut(new D2Point(x, y), D4Rect.LTRB(270, 120, 470, 160)) == false) // [960x540] { DDMain.SetScreenSize(960, 540); } else if (DDUtils.IsOut(new D2Point(x, y), D4Rect.LTRB(530, 120, 800, 160)) == false) // [1440x810] { DDMain.SetScreenSize(1440, 810); } else if (DDUtils.IsOut(new D2Point(x, y), D4Rect.LTRB(270, 160, 470, 200)) == false) // [1920x1080] { DDMain.SetScreenSize(1920, 1080); } else if (DDUtils.IsOut(new D2Point(x, y), D4Rect.LTRB(530, 160, 800, 200)) == false) // [フルスクリーン] { int w = DDGround.MonitorRect.W; int h = (DDConsts.Screen_H * DDGround.MonitorRect.W) / DDConsts.Screen_W; if (DDGround.MonitorRect.H < h) { h = DDGround.MonitorRect.H; w = (DDConsts.Screen_W * DDGround.MonitorRect.H) / DDConsts.Screen_H; if (DDGround.MonitorRect.W < w) { throw new DDError(); } } DDMain.SetScreenSize(DDGround.MonitorRect.W, DDGround.MonitorRect.H); DDGround.RealScreenDraw_L = (DDGround.MonitorRect.W - w) / 2; DDGround.RealScreenDraw_T = (DDGround.MonitorRect.H - h) / 2; DDGround.RealScreenDraw_W = w; DDGround.RealScreenDraw_H = h; } else if (DDUtils.IsOut(new D2Point(x, y), D4Rect.LTRB(400, 240, 530, 280)) == false) { DDGround.MusicVolume += 0.01; } else if (DDUtils.IsOut(new D2Point(x, y), D4Rect.LTRB(550, 240, 690, 280)) == false) { DDGround.MusicVolume -= 0.01; } else if (DDUtils.IsOut(new D2Point(x, y), D4Rect.LTRB(700, 240, 900, 280)) == false) { DDGround.MusicVolume = DDConsts.DefaultVolume; } else if (DDUtils.IsOut(new D2Point(x, y), D4Rect.LTRB(400, 320, 530, 360)) == false) { DDGround.SEVolume += 0.01; } else if (DDUtils.IsOut(new D2Point(x, y), D4Rect.LTRB(550, 320, 690, 360)) == false) { DDGround.SEVolume -= 0.01; } else if (DDUtils.IsOut(new D2Point(x, y), D4Rect.LTRB(700, 320, 900, 360)) == false) { DDGround.SEVolume = DDConsts.DefaultVolume; } else if (DDUtils.IsOut(new D2Point(x, y), D4Rect.LTRB(270, 400, 600, 440)) == false) { TitleConfigResetPlayData(); } else if (DDUtils.IsOut(new D2Point(x, y), D4Rect.LTRB(830, 480, 930, 520)) == false) { break; } DDGround.MusicVolume = DoubleTools.ToRange(DDGround.MusicVolume, 0.0, 1.0); DDGround.SEVolume = DoubleTools.ToRange(DDGround.SEVolume, 0.0, 1.0); } DrawWall(); DrawTitleBack(); PrintByFont.SetPrint(); PrintByFont.Print(""); PrintByFont.Print(" 設定"); PrintByFont.Print(""); PrintByFont.Print(" 画面サイズ [960x540] [1440x810]"); PrintByFont.Print(" [1920x1080] [フルスクリーン]"); PrintByFont.Print(""); PrintByFont.Print(string.Format(" BGM音量 {0:F2} [上げる] [下げる] [デフォルト]", DDGround.MusicVolume)); PrintByFont.Print(""); PrintByFont.Print(string.Format(" SE音量 {0:F2} [上げる] [下げる] [デフォルト]", DDGround.SEVolume)); PrintByFont.Print(""); PrintByFont.Print(" プレイデータリセット"); PrintByFont.Print(""); PrintByFont.Print(" [戻る]"); DDEngine.EachFrame(); } }
private static void DrawWall() { { DDUtils.Approach(ref Game.I.BackgroundSlideRate, Game.I.Player.Y * 1.0 / GameConsts.FIELD_H, 0.99); D4Rect rect = DDUtils.AdjustRectExterior( new D2Size(GameConsts.FIELD_W, GameConsts.FIELD_H), new D4Rect(0, 0, DDConsts.Screen_W, DDConsts.Screen_H), Game.I.BackgroundSlideRate ); DDDraw.DrawRect(P_Field.ToPicture(), rect); } { const int MARGIN = 5; DDDraw.SetBright(0, 0, 0); DDDraw.DrawRect( Ground.I.Picture.WhiteBox, GameConsts.FIELD_L - MARGIN, GameConsts.FIELD_T - MARGIN, GameConsts.FIELD_W + MARGIN * 2, GameConsts.FIELD_H + MARGIN * 2 ); DDDraw.Reset(); } DX.GraphFilter( DDGround.MainScreen.GetHandle(), DX.DX_GRAPH_FILTER_GAUSS, 16, SCommon.ToInt(500.0) ); DDCurtain.DrawCurtain(0.2); //DDCurtain.DrawCurtain(-0.2); // DDGround.MainScreen をグレースケール化 { DX.GraphBlend( GrayScreen_R.GetHandle(), // ソース画像かつ出力先 DDGround.MainScreen.GetHandle(), // ブレンド画像 255, DX.DX_GRAPH_BLEND_RGBA_SELECT_MIX, DX.DX_RGBA_SELECT_BLEND_R, // 出力先に適用する R 値 DX.DX_RGBA_SELECT_BLEND_R, // 出力先に適用する G 値 DX.DX_RGBA_SELECT_BLEND_R, // 出力先に適用する B 値 DX.DX_RGBA_SELECT_SRC_A // 出力先に適用する A 値 ); // DX_RGBA_SELECT_SRC_R == ソース画像の R 値 // DX_RGBA_SELECT_SRC_G == ソース画像の G 値 // DX_RGBA_SELECT_SRC_B == ソース画像の B 値 // DX_RGBA_SELECT_SRC_A == ソース画像の A 値 // DX_RGBA_SELECT_BLEND_R == ブレンド画像の R 値 // DX_RGBA_SELECT_BLEND_G == ブレンド画像の G 値 // DX_RGBA_SELECT_BLEND_B == ブレンド画像の B 値 // DX_RGBA_SELECT_BLEND_A == ブレンド画像の A 値 DX.GraphBlend( GrayScreen_G.GetHandle(), DDGround.MainScreen.GetHandle(), 255, DX.DX_GRAPH_BLEND_RGBA_SELECT_MIX, DX.DX_RGBA_SELECT_BLEND_G, DX.DX_RGBA_SELECT_BLEND_G, DX.DX_RGBA_SELECT_BLEND_G, DX.DX_RGBA_SELECT_SRC_A ); DX.GraphBlend( GrayScreen_B.GetHandle(), DDGround.MainScreen.GetHandle(), 255, DX.DX_GRAPH_BLEND_RGBA_SELECT_MIX, DX.DX_RGBA_SELECT_BLEND_B, DX.DX_RGBA_SELECT_BLEND_B, DX.DX_RGBA_SELECT_BLEND_B, DX.DX_RGBA_SELECT_SRC_A ); DDDraw.DrawSimple(GrayScreen_R.ToPicture(), 0, 0); DDDraw.SetAlpha(0.5); DDDraw.DrawSimple(GrayScreen_G.ToPicture(), 0, 0); DDDraw.SetAlpha(0.333); DDDraw.DrawSimple(GrayScreen_B.ToPicture(), 0, 0); DDDraw.Reset(); } }
public static void Paste(Canvas2 dest, Canvas2 src, D4Rect rect) { Paste(dest, src, rect.L, rect.T, rect.W, rect.H); }
private static void TitleDDStart2() { WallBokashiRateDest = 0.0; WallZRateDest = 1.02; P_TitleBackWDest = 0; const int TGS_BACK_X = 830; const int TGS_BACK_Y = 460; double selRateBack = 0.0; DDEngine.FreezeInput(); for (; ;) { DrawWall(); DrawTitleBack(); DDDraw.DrawBegin(Ground.I.Picture.TitleBtnBack, TGS_BACK_X, TGS_BACK_Y); DDDraw.DrawZoom(1.0 + selRateBack * 0.15); DDDraw.DrawEnd(); NamedCrashMgr.AddLastDrawedCrash("BACK"); // <---- 描画 DDMouse.UpdatePos(); string pointingName = NamedCrashMgr.GetName(DDMouse.X, DDMouse.Y); if (pointingName == "BACK") { DDUtils.Approach(ref selRateBack, 1.0, 0.85); } else { DDUtils.Approach(ref selRateBack, 0.0, 0.93); } DDEngine.EachFrame(); // ★★★ EachFrame if (DDMouse.L.GetInput() == 1) { if (pointingName == "BACK") { break; } int x = DDMouse.X; int y = DDMouse.Y; if (DDUtils.IsOut(new D2Point(x, y), D4Rect.LTRB(330, 90, 640, 360)) == false) // 入口 { SaveData.HasSaveData = true; // kari using (Game game = new Game()) { game.Room = new Room0001(); game.Perform(); } // TODO TitleMain()まで戻るべき } } } }
public static bool IsOut(D2Point pt, D4Rect rect, double margin = 0.0) { return (pt.X < rect.L - margin || rect.R + margin < pt.X || pt.Y < rect.T - margin || rect.B + margin < pt.Y); }
/// <summary> /// 矩形1と矩形2が衝突しているか判定する。 /// </summary> /// <param name="rect1">矩形1の座標</param> /// <param name="rect2">矩形2の座標</param> /// <returns>衝突しているか</returns> public static bool IsCrashed_Rect_Rect(D4Rect rect1, D4Rect rect2) { return (rect1.L < rect2.R && rect2.L < rect1.R && rect1.T < rect2.B && rect2.T < rect1.B); }
/// <summary> /// 矩形1と点2が衝突しているか判定する。 /// </summary> /// <param name="rect1">矩形1の座標</param> /// <param name="pt2">点2の座標</param> /// <returns>衝突しているか</returns> public static bool IsCrashed_Rect_Point(D4Rect rect1, D2Point pt2) { return (rect1.L < pt2.X && pt2.X < rect1.R && rect1.T < pt2.Y && pt2.Y < rect1.B); }
public bool PlayerWasDead = false; // 死亡すると true にセットされる。 public void Perform() { DDUtils.Random = new DDRandom(1u, 1u, 1u, 1u); // 電源パターン確保のため DDCurtain.SetCurtain(); DDEngine.FreezeInput(); Func <bool> f_ゴミ回収 = SCommon.Supplier(this.E_ゴミ回収()); // reset { RippleEffect.Clear(); 画面分割.Enabled = false; } this.Player.Reset(false); // ★★★★★ ステータス反映 { this.Score = this.Status.Score; this.Player.Power = this.Status.PlayerPower; this.Zanki = this.Status.PlayerZanki; this.ZanBomb = this.Status.PlayerZanBomb; } for (this.Frame = 0; ; this.Frame++) { if (!this.Script.EachFrame()) // シナリオ進行 { break; } if (DDConfig.LOG_ENABLED) // チート機能 { if (DDKey.IsPound(DX.KEY_INPUT_PGUP)) { this.Player.Power += GameConsts.PLAYER_POWER_PER_LEVEL; } if (DDKey.IsPound(DX.KEY_INPUT_PGDN)) { this.Player.Power -= GameConsts.PLAYER_POWER_PER_LEVEL; } DDUtils.ToRange(ref this.Player.Power, 0, GameConsts.PLAYER_POWER_MAX); } if (DDInput.PAUSE.GetInput() == 1 && 10 < this.Frame) // ポーズ { this.Pause(); if (this.Pause_RestartGame) { GameMaster.RestartFlag = true; break; } if (this.Pause_ReturnToTitleMenu) { GameMaster.ReturnToTitleMenu = true; break; } } if (DDConfig.LOG_ENABLED && DDKey.GetInput(DX.KEY_INPUT_RETURN) == 1) { this.DebugPause(); } this.LastInput = this.Input; // 前回のプレイヤー入力を退避 // プレイヤー入力 { this.Input.Dir2 = 1 <= DDInput.DIR_2.GetInput(); this.Input.Dir4 = 1 <= DDInput.DIR_4.GetInput(); this.Input.Dir6 = 1 <= DDInput.DIR_6.GetInput(); this.Input.Dir8 = 1 <= DDInput.DIR_8.GetInput(); this.Input.Slow = 1 <= DDInput.A.GetInput(); this.Input.Shoot = 1 <= DDInput.B.GetInput(); this.Input.Bomb = 1 <= DDInput.C.GetInput(); } this.Player.LastX = this.Player.X; this.Player.LastY = this.Player.Y; startBornPlayer: if (1 <= this.Player.BornFrame) // プレイヤー登場中の処理 { int frm = this.Player.BornFrame - 1; if (GameConsts.PLAYER_BORN_FRAME_MAX < frm) { this.Player.BornFrame = 0; goto endBornPlayer; } this.Player.BornFrame++; double rate = (double)frm / GameConsts.PLAYER_BORN_FRAME_MAX; if (frm == 0) // init { this.Player.BornFollowX = GameConsts.FIELD_W * 0.5; this.Player.BornFollowY = GameConsts.FIELD_H * 1.2; } double approachingRate = 0.99 - 0.01 * frm; DDUtils.ToRange(ref approachingRate, 0.0, 1.0); DDUtils.Approach(ref this.Player.BornFollowX, this.Player.X, approachingRate); DDUtils.Approach(ref this.Player.BornFollowY, this.Player.Y, approachingRate); } endBornPlayer: //startDeadPlayer: if (1 <= this.Player.DeadFrame) // プレイヤー死亡中の処理 { int frm = this.Player.DeadFrame - 1; if (GameConsts.PLAYER_DEAD_FRAME_MAX < frm) { if (this.Zanki <= 0) // 残機不足のため終了 { GameMaster.ReturnToTitleMenu = true; break; } this.Zanki--; this.Player.Reset(true); goto startBornPlayer; } this.Player.DeadFrame++; if (frm == 0) // init { this.DeadPlayerMoment(); this.PlayerEffects.Add(SCommon.Supplier(Effects.PlayerDead(this.Player.X, this.Player.Y))); } goto endPlayerMove; } //endDeadPlayer: //startBombPlayer: if (1 <= this.Player.BombFrame) // ボム使用中の処理 { int frm = this.Player.BombFrame - 1; if (GameConsts.PLAYER_BOMB_FRAME_MAX < frm) { this.Player.BombFrame = 0; goto endBombPlayer; } this.Player.BombFrame++; if (frm == 0) // init { this.Player.Bomb(); } } endBombPlayer: //startPlayerMove: // プレイヤー移動 { bool d2 = this.Input.Dir2; bool d4 = this.Input.Dir4; bool d6 = this.Input.Dir6; bool d8 = this.Input.Dir8; double speed; if (this.Input.Slow) { speed = 2.5; } else { speed = 5.0; } double nanameSpeed = speed / Math.Sqrt(2.0); if (d2 && d4) // 左下 { this.Player.X -= nanameSpeed; this.Player.Y += nanameSpeed; } else if (d2 && d6) // 右下 { this.Player.X += nanameSpeed; this.Player.Y += nanameSpeed; } else if (d4 && d8) // 左上 { this.Player.X -= nanameSpeed; this.Player.Y -= nanameSpeed; } else if (d6 && d8) // 右上 { this.Player.X += nanameSpeed; this.Player.Y -= nanameSpeed; } else if (d2) // 下 { this.Player.Y += speed; } else if (d4) // 左 { this.Player.X -= speed; } else if (d6) // 右 { this.Player.X += speed; } else if (d8) // 上 { this.Player.Y -= speed; } DDUtils.ToRange(ref this.Player.X, 0.0, (double)GameConsts.FIELD_W); DDUtils.ToRange(ref this.Player.Y, 0.0, (double)GameConsts.FIELD_H); if (d4) // 左 { DDUtils.Minim(ref this.Player.XMoveFrame, 0); this.Player.XMoveFrame--; } else if (d6) // 右 { DDUtils.Maxim(ref this.Player.XMoveFrame, 0); this.Player.XMoveFrame++; } else { this.Player.XMoveFrame = 0; } if (d8) // 上 { DDUtils.Minim(ref this.Player.YMoveFrame, 0); this.Player.YMoveFrame--; } else if (d2) // 下 { DDUtils.Maxim(ref this.Player.YMoveFrame, 0); this.Player.YMoveFrame++; } else { this.Player.YMoveFrame = 0; } DDUtils.Approach(ref this.Player.XMoveRate, DDUtils.Sign(this.Player.XMoveFrame), 0.95); DDUtils.Approach(ref this.Player.YMoveRate, DDUtils.Sign(this.Player.YMoveFrame), 0.95); } endPlayerMove: if (this.Input.Slow) { DDUtils.Maxim(ref this.Player.SlowFrame, 0); this.Player.SlowFrame++; } else { DDUtils.Minim(ref this.Player.SlowFrame, 0); this.Player.SlowFrame--; } if (this.Input.Shoot) { DDUtils.Maxim(ref this.Player.ShootFrame, 0); this.Player.ShootFrame++; } else { DDUtils.Minim(ref this.Player.ShootFrame, 0); this.Player.ShootFrame--; } DDUtils.Approach(ref this.Player.SlowRate, this.Player.SlowFrame < 0 ? 0.0 : 1.0, 0.85); DDUtils.Approach(ref this.Player.ShootRate, this.Player.ShootFrame < 0 ? 0.0 : 1.0, 0.85); if (this.LastInput.Shoot && this.Input.Shoot && SCommon.IsRange(this.Player.SlowFrame, -1, 1)) // ? ショット中に低速・高速を切り替えた。 { this.Player.ShootRate = 0.0; } // ---- if (this.Input.Shoot && this.Player.DeadFrame == 0) // プレイヤー攻撃 { this.Player.Shoot(); } if (this.Input.Bomb && this.Player.DeadFrame == 0 && this.Player.BombFrame == 0 && 1 <= this.ZanBomb) // ボム使用 { this.ZanBomb--; this.Player.BombFrame = 1; } // 当たり判定 reset { this.PlayerCrashes.Clear(); this.GrazeCrashes.Clear(); this.EnemyCrashes.Clear(); this.ShotCrashes.Clear(); } this.Player.Put当たり判定(); // ==== // 描画ここから // ==== // Swap { DDSubScreen tmp = this.Field; this.Field = this.Field_Last; this.Field_Last = tmp; } using (this.Field.Section()) // フィールド描画 { // Walls { int filledIndex = -1; for (int index = 0; index < this.Walls.Count; index++) { Wall wall = this.Walls[index]; if (!wall.Draw()) { this.Walls[index] = null; } else if (wall.Filled) { filledIndex = index; } } for (int index = 0; index < filledIndex; index++) { this.Walls[index] = null; } this.Walls.RemoveAll(v => v == null); } RippleEffect.EachFrame(this.Field); this.EL_AfterDrawWalls.ExecuteAllTask(); // Shots { for (int index = 0; index < this.Shots.Count; index++) { Shot shot = this.Shots[index]; if (!shot.Draw()) { this.Shots[index] = null; } } this.Shots.RemoveAll(v => v == null); } this.EL_AfterDrawShots.ExecuteAllTask(); if (this.Player.DeadFrame == 0) { this.Player.Draw(); } this.EL_AfterDrawPlayer.ExecuteAllTask(); // Enemies { foreach (Enemy.Kind_e kind in new Enemy.Kind_e[] { Enemy.Kind_e.ENEMY, Enemy.Kind_e.TAMA, Enemy.Kind_e.ITEM, }) { for (int index = 0; index < this.Enemies.Count; index++) { Enemy enemy = this.Enemies[index]; if (enemy != null && enemy.Kind == kind) { if (!enemy.Draw()) { this.Enemies[index] = null; } } } } this.Enemies.RemoveAll(v => v == null); } this.EnemyEffects.ExecuteAllTask(); this.PlayerEffects.ExecuteAllTask(); // 当たり判定表示 // -- デバッグ用だが、ボタン設定に割り当てがあるので、常に使えるようにする。 if (1 <= DDInput.R.GetInput()) { this.Draw当たり判定(); } 画面分割.EachFrame(this.Field); } { DDUtils.Approach(ref this.BackgroundSlideRate, this.Player.Y * 1.0 / GameConsts.FIELD_H, 0.99); // HACK D4Rect rect = DDUtils.AdjustRectExterior( new D2Size(GameConsts.FIELD_W, GameConsts.FIELD_H), new D4Rect(0, 0, DDConsts.Screen_W, DDConsts.Screen_H), this.BackgroundSlideRate //this.Player.Y * 1.0 / GameConsts.FIELD_H ); DDDraw.DrawRect(this.Field.ToPicture(), rect); } { const int MARGIN = 5; DDDraw.SetBright(0, 0, 0); DDDraw.DrawRect( Ground.I.Picture.WhiteBox, GameConsts.FIELD_L - MARGIN, GameConsts.FIELD_T - MARGIN, GameConsts.FIELD_W + MARGIN * 2, GameConsts.FIELD_H + MARGIN * 2 ); DDDraw.Reset(); } DX.GraphFilter( DDGround.MainScreen.GetHandle(), DX.DX_GRAPH_FILTER_GAUSS, 16, SCommon.ToInt(500.0) ); DDCurtain.DrawCurtain(-0.2); DDDraw.DrawSimple(this.Field.ToPicture(), GameConsts.FIELD_L, GameConsts.FIELD_T); this.DrawStatus(); this.SurfaceManager.Draw(); // ==== // 描画ここまで // ==== foreach (Enemy enemy in this.Enemies.Iterate()) { if (!DDUtils.IsOut(new D2Point(enemy.X, enemy.Y), new D4Rect(0, 0, GameConsts.FIELD_W, GameConsts.FIELD_H))) // ? フィールド内 { DDUtils.CountDown(ref enemy.TransFrame); enemy.OnFieldFrame++; } } this.当たり判定(); if (this.AH_Grazed) { if ( 1 <= this.Player.BornFrame || 1 <= this.Player.DeadFrame ) { // 登場中・死亡中は何もしない。 } else { Ground.I.SE.SE_KASURI.Play(); this.Score++; } } if (this.AH_PlayerCrashedFlag) { if ( 1 <= this.Player.BornFrame || 1 <= this.Player.DeadFrame || 1 <= this.Player.BombFrame ) { // 登場中・死亡中・ボム使用中は何もしない。 } else { this.Player.DeadFrame = 1; // プレイヤー死亡 this.PlayerWasDead = true; } } if (Ground.I.HiScore < this.Score) { if (Ground.I.HiScore + 10L < this.Score) { Ground.I.HiScore -= this.Score; Ground.I.HiScore /= 2L; Ground.I.HiScore += this.Score; } else { Ground.I.HiScore++; } } f_ゴミ回収(); this.Enemies.RemoveAll(v => v.HP == -1); this.Shots.RemoveAll(v => v.Vanished); DDEngine.EachFrame(); // ★★★ ゲームループの終わり ★★★ } DDUtils.Maxim(ref Ground.I.HiScore, this.Score); // 確実な同期 // ★★★★★ ステータス反映 { this.Status.Score = this.Score; this.Status.PlayerPower = this.Player.Power; this.Status.PlayerZanki = this.Zanki; this.Status.PlayerZanBomb = this.ZanBomb; } DDMain.KeepMainScreen(); DDMusicUtils.Fade(); DDCurtain.SetCurtain(60, -1.0); foreach (DDScene scene in DDSceneUtils.Create(120)) { DDDraw.DrawRect(DDGround.KeptMainScreen.ToPicture(), 0, 0, DDConsts.Screen_W, DDConsts.Screen_H); DDEngine.EachFrame(); } // ★★★ end of Perform() ★★★ }
// // copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c // public static void DrawRect(DDPicture picture, D4Rect rect) { DrawRect(picture, rect.L, rect.T, rect.W, rect.H); }