示例#1
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(Game.boardW, Game.boardH);
            Console.SetBufferSize(Game.boardW, Game.boardH);
            Console.CursorVisible = false;
            Menu menu = new Menu();

            menu.Process();
        }
示例#2
0
        public void Process()
        {
            while (Switch)
            {
                ConsoleKeyInfo btn = Console.ReadKey(true);

                if (mode == Mode.menu)
                {
                    switch (btn.Key)
                    {
                    case ConsoleKey.UpArrow:
                    case ConsoleKey.DownArrow:
                        menu.Process(btn);
                        break;

                    case ConsoleKey.Enter:
                        switch (menumode)
                        {
                        case MenuMode.main:
                            MenuAction();
                            break;

                        case MenuMode.options:
                            OptionsAction();
                            break;

                        case MenuMode.colors:
                            ColorsAction();
                            break;
                        }
                        break;
                    }
                }
                else
                {
                    switch (btn.Key)
                    {
                    case ConsoleKey.UpArrow:
                    case ConsoleKey.DownArrow:
                    case ConsoleKey.LeftArrow:
                    case ConsoleKey.RightArrow:
                        game.Process(btn);
                        break;

                    case ConsoleKey.Tab:
                        game.Save();
                        break;
                    }
                }
                Thread.Sleep(speed);
            }
        }
示例#3
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();
                t.Abort();
                Menu menu = new Menu();
                menu.Process();
                break;
            }
        }