示例#1
0
    static void Main()
    {
        var hero = new HeroClass(100, 150, 0); // third counter - initial position horizontally

        Console.Write($"Velocity = {hero.Velocity}; H-Position = {hero.MovePosition}");
        Console.Write("\r");
        var keyInfo = Console.ReadKey();

        while (keyInfo.Key != ConsoleKey.Escape)
        {
            keyInfo = Console.ReadKey();
            switch (keyInfo.Key)
            {
            case ConsoleKey.UpArrow:
                hero.UpSpeed();
                break;

            case ConsoleKey.DownArrow:
                hero.DownSpeed();
                break;

            case ConsoleKey.RightArrow:
                hero.MoveRight();
                if (hero.MovePosition != 4)
                {
                    break;
                }
                else
                {
                    hero.MoveLeft();
                    break;
                }

            case ConsoleKey.LeftArrow:
                hero.MoveLeft();
                if (hero.MovePosition != -1)
                {
                    break;
                }
                else
                {
                    hero.MoveRight();
                    break;
                }

            default:
                break;
            }
            Console.Write($"Velocity = {hero.Velocity}; H-Position = {hero.MovePosition}");
            Console.Write("\r");
        }
        //IPoint p = new Point(2, 3);
        //Idoublepoint pp = new Point(3, 4);
        //Point ppp = new Point(2, 6, 6);
        //pp.XYdoublepoint = 10;
        //Console.Write("My Point: ");
        //PrintPoint(ppp);
    }