コード例 #1
0
        static void Main(string[] args)
        {
            GraphicsWindow.KeyDown += GraphicsWindow_KeyDown;
            Turtle.PenUp();
            GraphicsWindow.BrushColor = "Blue";
            var eat  = Shapes.AddRectangle(10, 10);
            var eatX = 200;
            var eatY = 200;
            var s    = 5;



            Shapes.Move(eat, eatX, eatY);
            while (true)
            {
                Turtle.Speed = s;
                Random r = new Random();
                int    v = r.Next(0, GraphicsWindow.Width);
                Turtle.Move(10);

                if (Turtle.X >= eatX - 5 && Turtle.X <= eatX + 15 && Turtle.Y >= eatY - 5 && Turtle.Y <= eatY + 15)
                {
                    eatX = r.Next(0, GraphicsWindow.Width);
                    eatY = r.Next(0, GraphicsWindow.Height);
                    Shapes.Move(eat, eatX, eatY);
                    if (s < 9)
                    {
                        s = s + 1;
                    }
                }
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            GraphicsWindow.KeyDown += GraphicsWindow_KeyDown;
            Turtle.PenUp();

            GraphicsWindow.BrushColor = "Red";
            var eat = Shapes.AddRectangle(10, 10);
            int x   = 200;
            int y   = 200;

            Shapes.Move(eat, x, y);

            Random rand = new Random();

            while (true)
            {
                Turtle.Move(10);
                if (Turtle.X >= x && Turtle.X <= x + 10 && Turtle.Y >= y && Turtle.Y <= y + 10)
                {
                    x = rand.Next(0, GraphicsWindow.Width);
                    y = rand.Next(0, GraphicsWindow.Height);
                    Shapes.Move(eat, x, y);
                }
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: KseniyaTarasevich/study
        static void Main(string[] args)
        {
            Turtle.PenUp();
            GraphicsWindow.KeyDown += GraphicsWindow_KeyDown;

            GraphicsWindow.BrushColor = "Red";
            var food = Shapes.AddRectangle(10, 10);

            int xFoodPosition = 200;
            int yFoodPosition = 200;

            Shapes.Move(food, xFoodPosition, yFoodPosition);

            Random rand = new Random();

            while (true)
            {
                Turtle.Move(10);

                if (Turtle.X >= xFoodPosition && Turtle.X <= xFoodPosition + 10 && Turtle.Y >= yFoodPosition && Turtle.Y <= yFoodPosition + 10)
                {
                    xFoodPosition = rand.Next(0, GraphicsWindow.Width);
                    yFoodPosition = rand.Next(0, GraphicsWindow.Height);
                    Shapes.Move(food, xFoodPosition, yFoodPosition);
                    Turtle.Speed += 1;
                }
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: ZetExerion/TurtleGame
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("");
            Console.WriteLine(" ИГРА ЧЕРЕПАШКА НА ОХОТЕ");



            GraphicsWindow.KeyDown += GraphicsWindow_KeyDown;
            Turtle.PenUp();

            //Создание еды
            int x = 200;
            int y = 200;

            GraphicsWindow.BrushColor = "Red";
            var eat = Shapes.AddRectangle(10, 10);

            Shapes.Move(eat, x, y);
            Random rand = new Random();


            while (true)
            {
                Turtle.Move(10);
                if (Turtle.X >= x && Turtle.X <= x + 10 && Turtle.Y >= y && Turtle.Y <= y + 10)
                {
                    x = rand.Next(0, GraphicsWindow.Width);
                    y = rand.Next(0, GraphicsWindow.Height);
                    Shapes.Move(eat, x, y);
                }
            }
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: Corsodix/repo
        static void Main(string[] args)
        {
            GraphicsWindow.KeyDown += GraphicsWindow_KeyDown;
            Turtle.PenUp();
            //Turtle.Speed = 4;

            GraphicsWindow.BrushColor = "Red";
            var food = Shapes.AddRectangle(10, 10);

            var xFood = 320;
            var yFood = 200;

            Shapes.Move(food, xFood, yFood);

            Random rand = new Random();


            while (true)
            {
                Turtle.Move(10);
                if (Turtle.X >= xFood && Turtle.X <= xFood + 10 && Turtle.Y >= yFood && Turtle.Y <= yFood + 10)
                {
                    xFood = rand.Next(0, GraphicsWindow.Width);
                    yFood = rand.Next(0, GraphicsWindow.Height);
                    Shapes.Move(food, xFood, yFood);
                    Turtle.Speed++;
                }
            }
        }
コード例 #6
0
 static void PrintVscl()
 {
     Turtle.Angle = 180;
     Turtle.Move(35);
     Turtle.PenUp();
     Turtle.Move(14);
 }
コード例 #7
0
ファイル: Program.cs プロジェクト: Yanekpl/Start
        static void Main(string[] args)
        {
            // управление черепахой, окно должно быть активным
            GraphicsWindow.KeyDown += GraphicsWindow_KeyDown;
            // указываем, что чертить линию передвижения не надо
            Turtle.PenUp();
            //вводим переменную "еда" и красим ее в красный цвет, добавляем переменные местоположения
            GraphicsWindow.BrushColor = "Red";
            var eat = Shapes.AddEllipse(10, 10);
            int x   = 100;
            int y   = 100;

            Shapes.Move(eat, x, y);
            Random escape_my_eat = new Random();

            // бесконечный цикл
            while (true)
            {
                Turtle.Move(10);
                if (Turtle.X >= x && Turtle.X <= x + 10 && Turtle.Y >= y && Turtle.Y <= y + 10)
                {
                    x = escape_my_eat.Next(0, GraphicsWindow.Width);
                    y = escape_my_eat.Next(0, GraphicsWindow.Height);
                    Shapes.Move(eat, x, y);
                    Turtle.Speed++;
                }
            }
        }
コード例 #8
0
        static void Main(string[] args)
        {
            int x = 200, y = 200;

            Turtle.Speed = 8;
            Turtle.PenUp();

            Random rand = new Random();

            GraphicsWindow.BrushColor = "Yellow";
            var food = Shapes.AddRectangle(10, 10);

            Shapes.Move(food, x, y);
            while (true)
            {
                if (Turtle.X <= x + 10 && Turtle.X >= x && Turtle.Y <= y + 10 && Turtle.Y >= y)
                {
                    x = rand.Next(0, GraphicsWindow.Width);
                    y = rand.Next(0, GraphicsWindow.Height);
                    Shapes.Move(food, x, y);
                }
                GraphicsWindow.KeyDown += GraphicsWindow_KeyDown;
                Turtle.Move(1);
            }
        }
コード例 #9
0
 static void PrintN()
 {
     Turtle.Angle = 0;
     Turtle.Move(25);
     Turtle.Angle = 135;
     Turtle.Move(35);
     Turtle.Angle = 0;
     Turtle.Move(25);
 }
コード例 #10
0
 static void PrintU()
 {
     Turtle.Angle = 180;
     for (int i = 0; i < 3; i++)
     {
         Turtle.Move(25);
         Turtle.TurnLeft();
     }
 }
コード例 #11
0
 static void PrintO()
 {
     Turtle.Angle = 0;
     for (int i = 0; i < 4; i++)
     {
         Turtle.Move(25);
         Turtle.TurnRight();
     }
 }
コード例 #12
0
 static void PrintW()
 {
     Turtle.Angle = 180;
     Turtle.Move(48);
     Turtle.Angle = 30;
     Turtle.Move(25);
     Turtle.Angle = 150;
     Turtle.Move(25);
     Turtle.Angle = 0;
     Turtle.Move(48);
 }
コード例 #13
0
 static void PrintY()
 {
     Turtle.Angle = 0;
     Turtle.Move(25);
     Turtle.Angle = 315;
     Turtle.Move(25);
     Turtle.Angle = 135;
     Turtle.Move(25);
     Turtle.Angle = 45;
     Turtle.Move(25);
 }
コード例 #14
0
ファイル: Program.cs プロジェクト: Folkmancer/TurtleGame
        static void Main(string[] args)
        {
            GraphicsWindow.KeyDown += GraphicsWindow_KeyDown;
            Turtle.PenUp();
            var eat = Shapes.AddRectangle(10, 10);

            Shapes.Move(eat, 200, 200);
            while (true)
            {
                Turtle.Move(10);
            }
        }
コード例 #15
0
        static void Main(string[] args)
        {
            GraphicsWindow.KeyDown += GraphicsWindow_KeyDown;
            Turtle.PenUp();

            GraphicsWindow.BrushColor = "Red";     // выбираем красный цвет
            var eat = Shapes.AddRectangle(10, 10); // рисуем квадрат
            int x   = 200;
            int y   = 200;

            Shapes.Move(eat, x, y); // ставим eat в координаты x, y

            Random rand = new Random();

            int Level = 1;

            Console.WriteLine("Level " + Level);

            while (true)
            {
                Turtle.Move(10);

                if ((Turtle.X >= x && Turtle.X <= x + 10) && (Turtle.Y >= y && Turtle.Y <= y + 10))
                {
                    x = rand.Next(0, GraphicsWindow.Width);
                    y = rand.Next(0, GraphicsWindow.Height);
                    Shapes.Move(eat, x, y);
                    Turtle.Speed++;
                    Level++;
                    Console.WriteLine("Level " + Level);
                }

                if (Level == 12)
                {
                    break;
                }

                Grence(Turtle.X, Turtle.Y, GraphicsWindow.Height, GraphicsWindow.Width);
            }

            PrintYouWin();
        }
コード例 #16
0
        static void Main(string[] args)
        {
            int width  = GraphicsWindow.Width = 600;
            int height = GraphicsWindow.Height = 600;

            GraphicsWindow.KeyDown += GraphicsWindow_KeyDown;
            //убрать шлейф за черепашкой
            Turtle.PenUp();

            GraphicsWindow.BrushColor = "red";
            var eat = Shapes.AddRectangle(10, 10);
            int x   = 200;
            int y   = 200;

            Shapes.Move(eat, x, y);

            Random rand = new Random();

            while (true)
            {
                Turtle.Move(10);
                if ((Turtle.X <= 0 && Turtle.Angle == 270) || (Turtle.X >= GraphicsWindow.Width && Turtle.Angle == 90) ||
                    (Turtle.Y <= 0 && Turtle.Angle == 0) || (Turtle.Y >= GraphicsWindow.Height && Turtle.Angle == 180))
                {
                    Turtle.Turn(180);
                }

                if (Turtle.X >= x && Turtle.X <= x + 10 && Turtle.Y >= y && Turtle.Y <= y + 10)
                {
                    x = rand.Next(0, GraphicsWindow.Width);
                    y = rand.Next(0, GraphicsWindow.Height);
                    Shapes.Move(eat, x, y);
                    Turtle.Speed++;
                }
            }
        }
コード例 #17
0
        static void Main(string[] args)
        {
            GraphicsWindow.KeyDown += GraphicsWindow_KeyDown;
            Console.Title           = "Догони куб 3 раза";

            Turtle.PenUp();
            Turtle.Speed = 4;

            // (food) - объект который нужно поймать 3 Раза.
            var food = Shapes.AddRectangle(10, 10);
            int x    = 30;
            int y    = 40;

            Shapes.Move(food, x, y);


            Random rnd = new Random();

            // Синий куб ускорения.
            GraphicsWindow.BrushColor = "Blue";
            var speed = Shapes.AddRectangle(40, 50);
            int x1    = 200;
            int y1    = 300;

            Shapes.Move(speed, x1, y1);

            GraphicsWindow.DrawText(200, 280, "Ускорься)");



            while (true)
            {   //                                              |
                //если координаты Черепахи и food пересекаются--+-- , food исчезает , затем рандомно(rnd) появляется на карте.

                /*                                              |
                 * скорость черепахи снижатся на 1, при каждом касании food'а.
                 */
                if (Turtle.X >= x && Turtle.X <= x + 20 && Turtle.Y >= y && Turtle.Y <= y + 20)
                {
                    x = rnd.Next(0, GraphicsWindow.Width);
                    y = rnd.Next(0, GraphicsWindow.Height);
                    Shapes.Move(food, x, y);
                    Turtle.Speed--;

                    GraphicsWindow.BrushColor = "Red";
                    GraphicsWindow.DrawText(200, 260, "Осталось 2 раза =)");

                    if (Turtle.X >= x && Turtle.X <= x + 20 && Turtle.Y >= y && Turtle.Y <= y + 20)
                    {
                        GraphicsWindow.BrushColor = "Red";
                        GraphicsWindow.DrawText(200, 260, "Осталось 2 раза =)");
                    }
                }

                // Синий куб ускорения.
                if (Turtle.X >= x1 && Turtle.X <= x1 + 35 && Turtle.Y >= y1 && Turtle.Y <= y1 + 35)
                {
                    Turtle.Speed = 7;
                }
                Turtle.Move(10);
            }
        }
コード例 #18
0
        static void Main()
        {
            string s;

            TextWindow.Show();

            // запрашиваем размер еды и проверяем на допустимость
            do
            {
                TextWindow.WriteLine("Введите размер еды от 10 до 50px");
                s = TextWindow.Read();
            } while (!((int.TryParse(s, out int i)) && int.Parse(s) >= 10 && int.Parse(s) <= 50));

            TextWindow.Hide();

            int eatSize = int.Parse(s);

            Turtle.Speed = 4;
            Turtle.PenUp();

            GraphicsWindow.CanResize  = false;
            GraphicsWindow.BrushColor = "Red";
            var eat = Shapes.AddRectangle(eatSize, eatSize);
            int x   = 200;
            int y   = 200;

            Shapes.Move(eat, x, y);

            Random rand = new Random();

            GraphicsWindow.Title    = "Погнали!";
            GraphicsWindow.KeyDown += GraphicsWindow_KeyDown;

            while (true)
            {
                Turtle.Move(10);
                if (Turtle.X >= x && Turtle.X <= x + eatSize && Turtle.Y >= y && Turtle.Y <= y + eatSize)
                {
                    if (Turtle.Speed < 9)
                    {
                        Turtle.Speed++;
                    }
                    if (Turtle.Speed < 9)
                    {
                        GraphicsWindow.Title = "Переключились на скорость: " + (Turtle.Speed - 3);
                    }
                    else if (Turtle.Speed == 9 && GraphicsWindow.BrushColor != "Yellow")
                    {
                        GraphicsWindow.Title           = "Вышли на максимальную скорость!";
                        GraphicsWindow.BackgroundColor = "Red";
                        GraphicsWindow.BrushColor      = "Yellow";
                        Shapes.Remove(eat);
                        eat = Shapes.AddRectangle(eatSize, eatSize);
                    }

                    x = rand.Next(eatSize, GraphicsWindow.Width - eatSize);
                    y = rand.Next(eatSize, GraphicsWindow.Height - eatSize);
                    Shapes.Move(eat, x, y);
                }
            }
        }
コード例 #19
0
 static void PrintI()
 {
     Turtle.Angle = 0;
     Turtle.Move(25);
 }