예제 #1
0
        public void MoveUp(ConsoleRectangle rect)
        {
            if (rect.Location.Y == 0)
            {
                Console.WriteLine("Cant go higher");
                return;
            }

            rect.Location.Y--;
            rect.Draw();
        }
예제 #2
0
        public void MoveLeft(ConsoleRectangle rect)
        {
            if (rect.Location.X == 0)
            {
                Console.WriteLine("Cant go out of border");
                return;
            }

            rect.Location.X--;
            rect.Draw();
        }
예제 #3
0
        public void Run()
        {
            Console.SetWindowSize(110, 35);
            ConsolePrinter printer = new ConsolePrinter();

            // X and Y will initially be set to 0,0 ;
            // Create new Instance of Point to modify
            ConsoleRectangle rect = new ConsoleRectangle(10, 5, new Point());

            rect.Draw();


            while (true)
            {
                var inputChar = printer.ReadInput();
                Console.Clear();
                Move(inputChar, rect);
            }
        }
예제 #4
0
        private static void Move(ConsoleKey input, ConsoleRectangle rect)
        {
            switch (input)
            {
            case ConsoleKey.Escape:
                return;

            case ConsoleKey.UpArrow:
                rect.MoveUp(rect);
                break;

            case ConsoleKey.DownArrow:
                rect.MoveDown(rect);
                break;

            case ConsoleKey.LeftArrow:
                rect.MoveLeft(rect);
                break;

            case ConsoleKey.RightArrow:
                rect.MoveRight(rect);
                break;

            case ConsoleKey.R:
                Console.Write("Width: ");
                int width = Convert.ToInt32(Console.ReadLine());

                Console.Write("Height: ");
                int height = Convert.ToInt32(Console.ReadLine());

                rect = rect.Resize(width, height);
                Console.Clear();
                rect.Draw();
                break;
            }
        }
예제 #5
0
 public void MoveDown(ConsoleRectangle rect)
 {
     rect.Location.Y++;
     rect.Draw();
 }
예제 #6
0
 public void MoveRight(ConsoleRectangle rect)
 {
     rect.Location.X++;
     rect.Draw();
 }