Ejemplo n.º 1
0
        public void KeyPressed(ConsoleKeyInfo pressedKey)
        {
            if (cnt > 3)
            {
                wall = new Wall('#', ConsoleColor.DarkYellow, @"Levels/level2.txt");
            }


            change = false;
            switch (pressedKey.Key)
            {
            case ConsoleKey.UpArrow:
                w.ChangeDirection(0, -1);
                break;

            case ConsoleKey.DownArrow:
                w.ChangeDirection(0, 1);
                break;

            case ConsoleKey.LeftArrow:
                w.ChangeDirection(-1, 0);
                break;

            case ConsoleKey.RightArrow:
                w.ChangeDirection(1, 0);
                break;

            case ConsoleKey.S:
                w.Save("worm");
                break;

            case ConsoleKey.L:
                wormTimer.Stop();
                w.Clear();
                f    = new Food('@', ConsoleColor.Yellow);
                wall = new Wall('#', ConsoleColor.DarkYellow, @"Levels/level1.txt");
                w    = Worm.Load("worm");
                wormTimer.Start();
                break;

            case ConsoleKey.Escape:
                IsRunning = false;
                // wormTimer.Stop();
                break;

            case ConsoleKey.Spacebar:
                if (!pause)
                {
                    wormTimer.Stop();
                    pause = true;
                }
                else
                {
                    wormTimer.Start();
                    pause = false;
                }
                break;
            }
        }