示例#1
0
        public void Process(ConsoleKeyInfo pressedButton)
        {
            switch (pressedButton.Key)
            {
            case ConsoleKey.UpArrow:
                worm.Clear();
                worm.DX = 0;
                worm.DY = -1;
                worm.Draw();
                wall.Draw();
                break;

            case ConsoleKey.DownArrow:
                worm.Clear();
                worm.DX = 0;
                worm.DY = 1;
                worm.Draw();
                wall.Draw();
                break;

            case ConsoleKey.LeftArrow:
                worm.Clear();
                worm.DX = -1;
                worm.DY = 0;
                worm.Draw();
                wall.Draw();
                break;

            case ConsoleKey.RightArrow:
                worm.Clear();
                worm.DX = 1;
                worm.DY = 0;
                worm.Draw();
                wall.Draw();
                break;

            case ConsoleKey.Escape:
                Environment.Exit(0);
                break;

            case ConsoleKey.F2:
                worm.Save();
                food.Save();
                break;

            case ConsoleKey.F1:
                worm = worm.Load() as Worm;
                food = food.Load() as Food;
                break;
            }
        }
示例#2
0
 public void Draw()
 {
     if (!gameOver)
     {
         worm.Draw();
         food.Draw();
         wall.Draw();
     }
 }