Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SnakeGameWindow"/> class.
        /// </summary>
        public SnakeGameWindow(SnakeGameGUI snakeGameGUI)
        {
            this.snakeGameGUI = snakeGameGUI;
            gridWidth         = snakeGameGUI.GridGUI.GridWidth;
            gridHeight        = snakeGameGUI.GridGUI.GridHeight;
            sideLength        = snakeGameGUI.GridGUI.SideLength;

            SetUpBitMap();
            SetUpLabels();
            SetUpButtons();
            AddControls();
            // Enables double buffering to smooth the rendering.
            EnableDoubleBuffering();
            // Timer to control the framerate.
            Timer          = new Timer();
            Timer.Interval = 1;

            SetUpEventArguments();
            SetUpWindowSettings();
            // Start the timer, which starts the game.
            Timer.Start();
        }
Пример #2
0
 /// <summary>
 /// Runs a GUI window of the snake game.
 /// </summary>
 public void StartGUI()
 {
     withGUI      = true;
     snakeGameGUI = new SnakeGameGUI(snakeSettings, this);
     snakeGameGUI.OpenGameWindow();
 }