Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            string side = "top";
            Random u    = new Random();
            int    o    = u.Next(1, 9);
            int    p    = u.Next(1, 9);

            char[,] slide = new char[10, 10];

            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    if ((i == 0) || (i == 9) || (j == 0) || (j == 9))
                    {
                        slide[i, j] = '*';
                    }
                    else
                    {
                        slide[i, j] = ' ';
                    }
                }
            }

            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    Console.Write(slide[i, j]);
                    if (j == 9)
                    {
                        Console.Write("\n");
                    }
                }
            }

            List <coordinate> newcoordinate = new List <coordinate>();
            coordinate        a             = new coordinate
            {
                xi = 4,
                yj = 5
            };
            coordinate b = new coordinate
            {
                xi = 4,
                yj = 6
            };
            coordinate c = new coordinate
            {
                xi = 4,
                yj = 7
            };
            coordinate d = new coordinate
            {
                xi = 4,
                yj = 8
            };

            newcoordinate.Add(a);
            newcoordinate.Add(b);
            newcoordinate.Add(c);
            newcoordinate.Add(d);
            CreateFrog(newcoordinate, slide, o, p, u);
            /////////////////////
            System.Timers.Timer t = new System.Timers.Timer();
            t.Elapsed += (sender, e) => ElapsedEventHandler(sender, e, side, newcoordinate, slide, o, p, u);
            t.Interval = 2000;
            t.Enabled  = true;
            /////////////////////
            //for (int f = 0; f < newcoordinate.Count; f++)
            //{
            //    for (int i = 0; i < 10; i++)
            //    {
            //        for (int j = 0; j < 10; j++)
            //        {
            //            if ((newcoordinate.ElementAt(f).xi == i)&& (newcoordinate.ElementAt(f).yj == j))
            //            {
            //                Console.SetCursorPosition(i,j);
            //                Console.Write("q");
            //            }
            //        }
            //    }
            //}


            bool noexit = true;

            while (noexit)
            {
                char q = Console.ReadKey(true).KeyChar;
                if (q == 'a')
                {
                    if (side == "top")
                    {
                        side = "left";
                    }
                    else if (side == "bot")
                    {
                        side = "right";
                    }
                    else if (side == "left")
                    {
                        side = "bot";
                    }
                    else if (side == "right")
                    {
                        side = "top";
                    }
                }
                else if (q == 'd')
                {
                    if (side == "top")
                    {
                        side = "right";
                    }
                    else if (side == "bot")
                    {
                        side = "left";
                    }
                    else if (side == "left")
                    {
                        side = "top";
                    }
                    else if (side == "right")
                    {
                        side = "bot";
                    }
                }

                if (q == 'o')
                {
                    noexit = false;
                }
            }



            Console.Read();
        }