示例#1
0
        // ~exit events

        // GameWindow events
        private void GameWindow_KeyDown(object sender, KeyEventArgs e)
        {
            if (isGameOver)
            {
                return;
            }
            snakeSpeed.Enabled = false;
            switch (e.KeyCode)
            {
            case Keys.W: board.changeSnakeDirection(Direction.NORTH); break;

            case Keys.S: board.changeSnakeDirection(Direction.SOUTH); break;

            case Keys.A: board.changeSnakeDirection(Direction.WEST); break;

            case Keys.D: board.changeSnakeDirection(Direction.EAST); break;
            }
            gameAdvance();
            snakeSpeed.Enabled = true;
        }