Ejemplo n.º 1
0
        public Game()
        {
            gameLevel = GameLevel.First;

            worm = new Worm(new Point {
                X = 10, Y = 10
            }, ConsoleColor.White, '0');
            food = new Food(new Point {
                X = 20, Y = 10
            }, ConsoleColor.White, '@');
            wall = new Wall(null, ConsoleColor.White, '#');

            g_objects.Add(worm);
            g_objects.Add(food);
            g_objects.Add(wall);
            LoadLvl(k);
        }
Ejemplo n.º 2
0
        public void Process(ConsoleKeyInfo pressedButton)
        {
            switch (pressedButton.Key)
            {
            case ConsoleKey.UpArrow:
                worm.DX = 0;
                worm.DY = -1;
                break;

            case ConsoleKey.DownArrow:
                worm.DX = 0;
                worm.DY = 1;
                break;

            case ConsoleKey.LeftArrow:
                worm.DX = -1;
                worm.DY = 0;
                break;

            case ConsoleKey.RightArrow:
                worm.DX = 1;
                worm.DY = 0;
                break;

            case ConsoleKey.Escape:
                Console.Clear();
                Menu menu = new Menu();
                menu.Process();
                Console.ReadKey();
                break;

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

            case ConsoleKey.F1:
                worm = worm.Load() as Worm;
                food = food.Load() as Food;
                break;
            }
        }