Esempio n. 1
0
        /// <summary>
        /// Occurs when key preesed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void OnKeyDown(KeyEventArgs e)
        {
            if (IsStartGame)
            {
                switch (e.KeyCode)
                {
                case Keys.W:
                    snake.GoUp();
                    break;

                case Keys.S:
                    snake.GoDown();
                    break;

                case Keys.D:
                    snake.GoRight();
                    break;

                case Keys.A:
                    snake.GoLeft();
                    break;
                }
            }
            base.OnKeyDown(e);
        }