コード例 #1
0
        static void Main(string[] args)
        {
            //get WindowHeight and WindowWidth
            int maxheight = Console.WindowHeight;
            int maxwidth  = Console.WindowWidth;

            //for (int i = 1; i <= maxheight; i++)
            //    Console.WriteLine(i);

            //Console.Clear();

            //print a '*' in the middle of the console
            //Console.SetCursorPosition(maxwidth / 2, maxheight / 2);
            //Console.Write("*");

            //Assigning x and y coordinates to the middle of the screen
            int x = maxwidth / 2;

            int y = maxheight / 2;

            Console.CursorVisible = false;

            //Create Player Object
            Player pl = new Player();

            MZEnd end = new MZEnd('☺', 40, 20);

            //Create Maze Object
            Maze mz = new Maze();

            pl.SetMazePointer(mz);
            mz.CreateMaze();
            end.Print();
            pl.SetEndPointer(end);



            //Use ReadyKey to move the character. Use var to get the return and figure out how to check for UpArrow
            while (true)
            {
                //Creare variable to store key information
                ConsoleKeyInfo i = new ConsoleKeyInfo();
                var            noKeyPressedYet = i.Key;

                //Take info from console if a key is available in the buffer
                if (Console.KeyAvailable)
                {
                    i = Console.ReadKey(true);
                    pl.Move(i, 1);
                    end.Print();
                }
            }
        }
コード例 #2
0
 public void SetEndPointer(MZEnd mzend)
 {
     end = mzend;
 }