コード例 #1
0
        public void Run()
        {
            app.SetMouseCursorVisible(false);
            SetMousePointerInTheMiddleOfTheScreen();

            // Start the game loop
            while (app.IsOpen)
            {
                // Process events
                app.DispatchEvents();

                if (!Pause)
                {
                    SetMousePointerInTheMiddleOfTheScreen();
                }

                game.Action();

                DrawBackground(app);
                DrawBorders(app);
                DrawBricks(app);
                DrawPad(app);
                DrawBall(app);
                DrawTexts(app);

                // Update the window
                app.Display();
            }

            font?.Dispose();
            background?.Dispose();
        }
コード例 #2
0
        /// <summary>
        ///     Обрабатывает нажатие клавиши на клавиатуре
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnKeyDown(object sender, KeyEventArgs e)
        {
            if (gameState != State.Running)
            {
                return;
            }

            if (ControlActions.StopTime == GUI.Controls.ControlFromKey(e.KeyCode))
            {
                Pause();
            }
            else
            {
                _game.Action(
                    $"key_down {GUI.Controls.ControlFromKey(e.KeyCode)}"); //.Add(GUI.Controls.ControlFromKey(e.KeyCode));
            }
        }
コード例 #3
0
 public void WinCondTests(string a1, string a3, string a2)
 {
     (game as GameXO).SetTest();
     game.Action("1", a1);
     game.Action("1", a2);
     game.Action("1", a3);
     Assert.AreEqual(GameState.EndWithWinner, game.CurrentState);
     Assert.AreEqual("1", game.Winner);
 }