Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Game     game      = new Game();
            SportCar sportCar1 = new SportCar();
            SportCar sportCar2 = new SportCar();

            game.ReadyToStart(sportCar1, sportCar2);

            Console.ReadKey();
        }
Exemplo n.º 2
0
        public void ReadyToStart(SportCar sp, SportCar sp2)
        {
            winner       = (Car)null;
            sp.Driving  += CarDriving;
            sp2.Driving += CarDriving;
            sp.Finish   += CarFinish;
            sp2.Finish  += CarFinish;
            sp.GetReady();
            sp2.GetReady();
            Console.Clear();
            Console.WriteLine("3");
            Thread.Sleep(1000);
            Console.Clear();
            Console.WriteLine("2");
            Thread.Sleep(1000);
            Console.Clear();
            Console.WriteLine("1");
            Thread.Sleep(1000);
            Console.Clear();
            Console.WriteLine("Поехали!");
            Thread.Sleep(800);
            Console.Clear();

            for (float t = 0; ; t += 0.1F)
            {
                Console.SetCursorPosition(0, 0);

                sp.Drive(t, 400);
                sp2.Drive(t, 400);
                Thread.Sleep(100);
                if (winner != null)
                {
                    break;
                }
            }
            Console.WriteLine("Победил: " + winner.Name);
        }