private void GameboardKeyDown(object sender, KeyEventArgs e)
        {
            TestLabel.Content = e.Key.ToString();
            switch (e.Key)
            {
            case Key.Left:
            case Key.A:
                Gameboard.MoveLeft();
                break;

            case Key.Down:
            case Key.S:
                Gameboard.MoveDown();
                break;

            case Key.Right:
            case Key.D:
                Gameboard.MoveRight();
                break;

            case Key.Up:
            case Key.W:
                Gameboard.MoveUp();
                break;
            }

            UpdateBoard();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            bool           playing   = true;
            GameboardClass Gameboard = new GameboardClass();



            while (playing)
            {
                Gameboard.AddRandomToBoard();
                Gameboard.DisplayGrid();

                String input = Console.ReadLine();

                switch (input)
                {
                case "w":
                    Gameboard.MoveUp();
                    break;

                case "a":
                    Gameboard.MoveLeft();
                    break;

                case "s":
                    Gameboard.MoveDown();
                    break;

                case "d":
                    Gameboard.MoveRight();
                    break;

                case "b":
                    playing = false;
                    break;
                }

                if (Gameboard.CheckGameOver())
                {
                    Console.WriteLine("Game over");
                    playing = false;
                }



                Console.ReadLine();
            }
        }