Exemple #1
0
        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;
                }
            }
        }
        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);
                }
            }
        }
        static void Main(string[] args)
        {
            GraphicsWindow.KeyDown += GraphicsWindow_KeyDown;

            Turtle.PenUp();

            GraphicsWindow.BrushColor = "Red";

            var    eat     = Shapes.AddRectangle(10, 10);
            var    eatPosX = 200;
            var    eatPosY = 200;
            Random rand    = new Random();

            Shapes.Move(eat, eatPosX, eatPosY);

            while (true)
            {
                Turtle.Move(10);
                if (Turtle.X >= eatPosX &&
                    Turtle.X <= eatPosX + 10 &&
                    Turtle.Y >= eatPosY &&
                    Turtle.Y <= eatPosY + 10)
                {
                    eatPosX = rand.Next(0, GraphicsWindow.Width);
                    eatPosY = rand.Next(0, GraphicsWindow.Height);
                    Shapes.Move(eat, eatPosX, eatPosY);
                    Turtle.Speed += 1;
                }
            }
        }
Exemple #4
0
        static void Main(string[] args)
        {
            Random rand = new Random();

            // Не оставлять след
            Turtle.PenUp();

            // Добавление еды
            GraphicsWindow.BrushColor = "Green";
            var food  = Shapes.AddRectangle(10, 10);
            int foodX = 200;
            int foodY = 200;

            Shapes.Move(food, foodX, foodY);

            while (true)
            {
                GraphicsWindow.KeyDown += GraphicsWindow_KeyDown;
                Turtle.Move(10);
                if ((Turtle.X >= foodX - 10 && Turtle.X <= foodX + 10) && (Turtle.Y >= foodY - 10 && Turtle.Y <= foodY + 10))
                {
                    foodX = rand.Next(0, GraphicsWindow.Width);
                    foodY = rand.Next(0, GraphicsWindow.Height);
                    Shapes.Move(food, foodX, foodY);
                    Turtle.Speed++;
                }
            }
        }
Exemple #5
0
        static void Main(string[] args)
        {
            GraphicsWindow.Title  = "Turtle eat";
            GraphicsWindow.Width  = 800;
            GraphicsWindow.Height = 700;

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

            GraphicsWindow.BrushColor = "Red";
            var eat = Shapes.AddRectangle(10, 10);
            var xx  = 100;
            var yy  = 200;

            Shapes.Move(eat, xx, yy);
            Random rand = new Random();

            while (true)
            {
                Turtle.Move(10);
                if (Turtle.X <= (xx + 15) && Turtle.X > (xx - 10) && Turtle.Y <= (yy + 15) && Turtle.Y > (yy - 10))
                {
                    xx = rand.Next(GraphicsWindow.Width);
                    yy = rand.Next(GraphicsWindow.Height);
                    Shapes.Move(eat, xx, yy);
                    Turtle.Speed++;
                }
            }
        }
Exemple #6
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;
                    }
                }
            }
        }
Exemple #7
0
        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);
                }
            }
        }
Exemple #8
0
        static void Main(string[] args)
        {
            //Pila();
            //Six();
            //Moloko();
            GraphicsWindow.KeyDown += GraphicsWindow_KeyDown;
            Turtle.PenUp();

            int moveFoodX = 150;
            int moveFoodY = 150;

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

            Shapes.Move(food, moveFoodX, moveFoodY);

            Random random = new Random();

            while (true)
            {
                if (Turtle.X - moveFoodX < 15 && Turtle.Y - moveFoodY < 15 && moveFoodX - Turtle.X < 15 && moveFoodY - Turtle.Y < 15)
                {
                    moveFoodX = random.Next(0, GraphicsWindow.Width);
                    moveFoodY = random.Next(0, GraphicsWindow.Height);
                    Shapes.Move(food, moveFoodX, moveFoodY);
                    Turtle.Speed++;
                }
                Turtle.Move(10);
            }
        }
Exemple #9
0
        static void Main(string[] args)
        {
            GraphicsWindow.KeyDown += GraphicsWindow_KeyDown;
            Turtle.PenUp();
            GraphicsWindow.BrushColor = "Green";
            var    eat = Shapes.AddRectangle(10, 10);
            int    x, y, life = 3;
            int    score = 0;
            Random rand  = new Random();

            x = rand.Next(0, GraphicsWindow.Width);
            y = rand.Next(0, GraphicsWindow.Height);
            Shapes.Move(eat, x, y);
            while (life > 0)
            {
                Turtle.Move(1);
                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++;
                    score++;

                    GraphicsWindow.DrawText(GraphicsWindow.Width - 100, GraphicsWindow.Height - 100, score);
                }
                else if (Turtle.X < 0 || Turtle.X > GraphicsWindow.Width || Turtle.Y < 0 || Turtle.Y > GraphicsWindow.Height)
                {
                    Turtle.X = GraphicsWindow.Width / 2;
                    Turtle.Y = GraphicsWindow.Height / 2;
                    life--;
                }
            }
        }
Exemple #10
0
        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++;
                }
            }
        }
Exemple #11
0
        static void Main(string[] args)
        {
            Console.WriteLine("click Enter to start");
            Console.ReadLine();
            GraphicsWindow.KeyDown += GraphicsWindow_KeyDown;
            Turtle.PenUp();

            GraphicsWindow.BrushColor = "Blue";
            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 + 12 && Turtle.Y >= y && Turtle.Y <= y + 12)
                {
                    x = rand.Next(0, GraphicsWindow.Width);
                    y = rand.Next(0, GraphicsWindow.Height);
                    Shapes.Move(eat, x, y);
                    Turtle.Speed++;
                }
            }
        }
Exemple #12
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);
            }
        }
Exemple #13
0
        public static Primitive Food(int x, int y)
        {
            GraphicsWindow.BrushColor = "Red";
            var food = Shapes.AddRectangle(12, 12);

            Shapes.Move(food, 300, 300);
            return(food);
        }
Exemple #14
0
        static void Main(string[] args)
        {
            GraphicsWindow.KeyDown += GraphicsWindow_KeyDown;
            Turtle.PenUp();
            // Turtle.Speed = 9;
            GraphicsWindow.Height     = 800;
            GraphicsWindow.Width      = 600;
            GraphicsWindow.BrushColor = "White";
            var playzone = Shapes.AddRectangle(800, 600);

            GraphicsWindow.BrushColor = "Purple";
            var food      = Shapes.AddRectangle(20, 20);
            int score     = 0;
            var scoreText = Shapes.AddText(score);

            Shapes.Zoom(scoreText, 5, 5);
            Shapes.Move(scoreText, 900, 50);

            Random r     = new Random();
            int    foodX = r.Next(0, 800);
            int    foodY = r.Next(0, 600);

            //int foodX = 100;
            //int foodY = 200;
            Shapes.Move(food, foodX, foodY);
            while (true)
            {
                Turtle.Move(10);
                if (Turtle.X.GreaterThan(foodX) && Turtle.X.LessThan(foodX + 20) && Turtle.Y.GreaterThan(foodY) && Turtle.Y.LessThan(foodY + 20))
                {
                    //foodX = foodX + 25; // перемещение еды согласно заданию
                    foodX = r.Next(0, 780); // случайное появление еды
                    foodY = r.Next(0, 580);
                    Shapes.Move(food, foodX, foodY);
                    score++;
                    Shapes.SetText(scoreText, score);
                }
                if (Turtle.X.GreaterThan(800))
                {
                    Turtle.X = 0;
                }
                if (Turtle.X.LessThan(0))
                {
                    Turtle.X = 800;
                }
                if (Turtle.Y.GreaterThan(600))
                {
                    Turtle.Y = 0;
                }
                if (Turtle.Y.LessThan(0))
                {
                    Turtle.Y = 600;
                }
            }
        }
Exemple #15
0
        static void Main(string[] args)
        {
            GraphicsWindow.KeyDown   += GraphicsWindow_KeyDown;
            GraphicsWindow.MouseDown += GraphicsWindow_MouseDown;
            GraphicsWindow.MouseUp   += GraphicsWindow_MouseUp;
            Turtle.PenUp();
            GraphicsWindow.BrushColor = "Red";
            var eat = Shapes.AddRectangle(10, 10);

            Shapes.Move(eat, 200, 200);
            int    eatX  = 200;
            int    eatY  = 200;
            Random rnd   = new Random();
            int    count = 0;
            double step  = 3;

            GraphicsWindow.DrawText(0, 0, "Очки: " + Convert.ToString(count));
            while (true)
            {
                Turtle.Move(step);
                if ((Turtle.X <= eatX + 15) && (Turtle.X >= eatX - 5) && (Turtle.Y <= eatY + 15) && (Turtle.Y >= eatY - 5))
                {
                    GraphicsWindow.BrushColor = "White";
                    GraphicsWindow.DrawText(0, 0, "Очки: " + Convert.ToString(count));
                    eatX = rnd.Next(10, GraphicsWindow.Width);
                    eatY = rnd.Next(10, GraphicsWindow.Height);
                    Shapes.Move(eat, eatX, eatY);
                    count++;
                    Turtle.Speed = Turtle.Speed + 0.1;
                    step         = step + 0.1;
                    GraphicsWindow.BrushColor = "Red";
                    GraphicsWindow.DrawText(0, 0, "Очки: " + Convert.ToString(count));
                }
                if (Turtle.X < 0)
                {
                    break;
                }
                else if (Turtle.X > GraphicsWindow.Width)
                {
                    break;
                }
                else if (Turtle.Y < 0)
                {
                    break;
                }
                else if (Turtle.Y > GraphicsWindow.Height)
                {
                    break;
                }
                //GraphicsWindow.DrawText(10, 10, "Очки: " + Convert.ToString(count));
            }
            GraphicsWindow.ShowMessage("Ваши очки: " + Convert.ToString(count), "Игра окончена!");
        }
Exemple #16
0
        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);
            }
        }
Exemple #17
0
        static void Main(string[] args)
        {
            GraphicsWindow.KeyDown   += GraphicsWindow_KeyDown;
            GraphicsWindow.BrushColor = "Yellow";
            Turtle.PenUp();
            var eat     = Shapes.AddRectangle(10, 10);
            int x1      = 200;
            int y1      = 200;
            int counter = 0;

            GraphicsWindow.BrushColor = "Red";
            GraphicsWindow.DrawText(10, 10, "Очки: " + counter);
            //Создание объекта для генерации чисел
            Random rnd = new Random();

            Shapes.Move(eat, x1, y1);
            while (true)
            {
                Turtle.Move(5);
                if ((Turtle.X <= x1 + 10) && (Turtle.X >= x1) && (Turtle.Y <= y1 + 10) && (Turtle.Y >= y1))
                {
                    GraphicsWindow.BrushColor = "White";
                    GraphicsWindow.DrawText(10, 10, "Очки: " + counter);
                    counter++;
                    GraphicsWindow.BrushColor = "Red";
                    GraphicsWindow.DrawText(10, 10, "Очки: " + counter);
                    x1 = rnd.Next(10, GraphicsWindow.Width);
                    y1 = rnd.Next(10, GraphicsWindow.Height);
                    Shapes.Move(eat, x1, y1);
                    Turtle.Speed = Turtle.Speed + 0.3;
                }
                if (Turtle.X > GraphicsWindow.Width)
                {
                    Turtle.X = 0;
                }
                else if (Turtle.X < 0)
                {
                    Turtle.X = GraphicsWindow.Width;
                }

                if (Turtle.Y < 0)
                {
                    Turtle.Y = GraphicsWindow.Height;
                }
                else if (Turtle.Y > GraphicsWindow.Height)
                {
                    Turtle.Y = 0;
                }
            }
        }
Exemple #18
0
        static void Main(string[] args)
        {
            GraphicsWindow.KeyDown += GraphicsWindow_KeyDown;
            Turtle.PenUp();

            GraphicsWindow.BrushColor      = "Black";
            GraphicsWindow.BackgroundColor = "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.X = GraphicsWindow.Width - 1;
                }
                if (Turtle.X >= GraphicsWindow.Width)
                {
                    Turtle.X = 0;
                }
                if (Turtle.Y <= 0)
                {
                    Turtle.Y = GraphicsWindow.Height - 1;
                }
                if (Turtle.Y >= GraphicsWindow.Height)
                {
                    Turtle.Y = 0;
                }                 //Сделано

                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++;
                }
            }
        }
Exemple #19
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();
        }
Exemple #20
0
        static void Main(string[] args)
        {
            GraphicsWindow.KeyDown += GraphicsWindow_KeyDown;
            Turtle.PenUp();
            GraphicsWindow.BrushColor = "#3CF665";
            var    eat  = Shapes.AddRectangle(20, 20);
            Random rand = new Random();
            int    eatX = rand.Next() % 600;
            int    eatY = rand.Next() % 420;

            Shapes.Move(eat, eatX, eatY);
            for (;;)
            {
                if (Turtle.X >= eatX && Turtle.X <= eatX + 20 && Turtle.Y >= eatY &&
                    Turtle.Y <= eatY + 20)
                {
                    Random rand1 = new Random();
                    eatX = rand1.Next() % 600;
                    eatY = rand1.Next() % 420;
                    Shapes.Move(eat, eatX, eatY);
                    Turtle.Speed += 1;
                }
                Turtle.Move(10);
                if (Turtle.X < 0)
                {
                    Turtle.X = 600;
                }
                if (Turtle.Y < 0)
                {
                    Turtle.Y = 420;
                }
                if (Turtle.X > 600)
                {
                    Turtle.X = 0;
                }
                if (Turtle.Y > 420)
                {
                    Turtle.Y = 0;
                }
            }
        }
Exemple #21
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++;
                }
            }
        }
Exemple #22
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);
                }
            }
        }
Exemple #23
0
        static void Main(string[] args)
        {
            GraphicsWindow.Show();
            var p = Shapes.AddRectangle(100, 20);

            Shapes.Move(p, 0, GraphicsWindow.Height - 20);
            GraphicsWindow.MouseMove += () => { Shapes.Move(p, GraphicsWindow.MouseX - 50, GraphicsWindow.Height - 20); };
            Primitive[] enemies = new Primitive[20];
            GraphicsWindow.BrushColor = "Gray";
            var c = Shapes.AddEllipse(20, 20);

            Timer.Interval = 10;
            int circleX = GraphicsWindow.Width / 2, circleY = GraphicsWindow.Height / 2, stepx = 2, stepy = 2, my = GraphicsWindow.Height - 40, mx = GraphicsWindow.MouseX;
            int enemyWidth = GraphicsWindow.Width / 10 - 5;

            Mouse.HideCursor();
            GraphicsWindow.BrushColor = "Red";
            for (int i = 0; i < 10; i++)
            {
                enemies[i] = Shapes.AddRectangle(enemyWidth, 20);
                Shapes.Move(enemies[i], i * (GraphicsWindow.Width / 10), 30);
            }
            for (int i = 0; i < 10; i++)
            {
                enemies[i] = Shapes.AddRectangle(enemyWidth, 20);
                Shapes.Move(enemies[i], i * (GraphicsWindow.Width / 10), 55);
            }

            Timer.Tick += () =>
            {
                my = GraphicsWindow.Height - 40;
                mx = GraphicsWindow.MouseX;
                Shapes.Move(c, circleX += stepx, circleY += stepy);
                if (circleX >= GraphicsWindow.Width - 20)
                {
                    stepx = -stepx;
                }
                if (circleX <= 0)
                {
                    stepx = 4;
                }
                if ((circleX >= mx - 50 && circleX <= mx + 50) && (circleY >= my))
                {
                    stepy = -stepy;
                }
                if (circleY <= 0)
                {
                    stepy = 4;
                }
                if (circleY > GraphicsWindow.Height)
                {
                    Sound.PlayAndWait("1.mp3");
                    Microsoft.SmallBasic.Library.Program.End();
                }
                for (int i = 0; i < 10; i++)
                {
                    if ((circleX + 10 >= Shapes.GetLeft(enemies[i])) && (circleY <= Shapes.GetTop(enemies[i]) + 20) && (circleX <= Shapes.GetLeft(enemies[i]) + enemyWidth))
                    {
                        Shapes.Move(enemies[i], 9999, 9999);
                        stepy = -stepy;
                    }
                }
            };
        }
Exemple #24
0
        private void buttonShapes_Click(object sender, EventArgs e)
        {
            GraphicsWindow.Show();
            LDScrollBars.Rasterize    = "True";
            GraphicsWindow.MouseDown += OnMouseDown;
            LDScrollBars.Add(GraphicsWindow.Width, 10000);
            int       cogRadius    = 100;
            int       cogNumTeeth  = 10;
            int       cogToothSize = 10;
            Primitive cog          = Shapes.AddEllipse(2 * cogRadius, 2 * cogRadius);
            Primitive points       = "";
            Primitive point        = "";

            LDPhysics.AddMovingShape(cog, 0.5, 0.8, 1);
            for (int i = 1; i <= 1; i++)
            {
                double angle       = (i - 1) / cogNumTeeth * 2 * SBMath.Pi;
                double innerSector = 0.7 / cogNumTeeth * 2 * SBMath.Pi;
                double outerSector = 0.5 / cogNumTeeth * 2 * SBMath.Pi;
                point["X"] = cogRadius + cogRadius * SBMath.Cos(angle);
                point["Y"] = cogRadius + cogRadius * SBMath.Sin(angle);
                points[1]  = point;
                point["X"] = cogRadius + cogRadius * SBMath.Cos(angle + innerSector);
                point["Y"] = cogRadius + cogRadius * SBMath.Sin(angle + innerSector);
                points[2]  = point;
                point["X"] = cogRadius + (cogRadius + cogToothSize) * SBMath.Cos(angle + outerSector);
                point["Y"] = cogRadius + (cogRadius + cogToothSize) * SBMath.Sin(angle + outerSector);
                points[3]  = point;
                point["X"] = cogRadius + (cogRadius + cogToothSize) * SBMath.Cos(angle + innerSector - outerSector);
                point["Y"] = cogRadius + (cogRadius + cogToothSize) * SBMath.Sin(angle + innerSector - outerSector);
                points[4]  = point;
                Primitive tooth = LDShapes.AddPolygon(points);
                LDPhysics.AddMovingShape(tooth, 0.5, 0.8, 1);
                //LDPhysics.GroupShapes(cog, tooth);
            }

            LDPhysics.DoTimestep();

            Primitive ball = Shapes.AddEllipse(100, 50);

            //Shapes.Move(ball, 112, 112);
            //Shapes.Zoom(ball, 1, 1);
            //Shapes.Rotate(ball, -60);
            Shapes.Move(ball, 100, 112);
            //Shapes.Zoom(ball, 1.2, 1);
            //Shapes.Rotate(ball, -60);

            Primitive gradient = "";

            gradient[1] = "Red";
            gradient[2] = "Yellow";
            gradient[3] = "Blue";
            Primitive brush = LDShapes.BrushGradient(gradient, "H");

            LDShapes.BrushShape(ball, brush);

            LDUtilities.GWCapture("C:\\temp\\test.jpg", "False");

            Primitive rect = Shapes.AddRectangle(60, 60);

            Shapes.Move(rect, 25, 95);
            Shapes.Zoom(rect, 1.5, 1);
            Shapes.Rotate(rect, 45);
            //Shapes.Move(rect, 75, 75);
            //Shapes.Zoom(rect, 1.5, 1);
            //Shapes.Rotate(rect, 45);

            TextWindow.WriteLine(LDShapes.Overlap(ball, rect));
            //TextWindow.WriteLine(LDShapes.Overlap(rect, ball));

            Primitive image1 = Shapes.AddImage("C:\\temp\\test2.jpg");

            Shapes.Move(image1, 100, 100);
            TextWindow.WriteLine(LDShapes.Overlap(ball, image1));

            //LDShapes.AnimatedGifInterval = 0;
            Primitive gifShape = LDShapes.AddAnimatedGif("http://www.animatedgif.net//animals//birds//batana1_e0.gif", "True");

            Shapes.Move(gifShape, 100, 300);
            Primitive rectangle = Shapes.AddRectangle(100, 100);

            LDShapes.BrushColour(rectangle, "Red");
            Primitive img    = SBImageList.LoadImage("C:\\temp\\test.jpg");
            Primitive img2   = "C:\\temp\\test2.jpg";
            Primitive button = SBControls.AddButton("TEST", 100, 100);

            SBControls.SetSize(button, 50, 50);
            Primitive image = Shapes.AddImage(img);

            LDShapes.ReSize(image, 50, 50);
            LDShapes.Centre(image, 400, 25);
            SBProgram.Delay(1000);
            LDShapes.SetImage(image, img2);
            LDShapes.SetImage(button, img);
            SBProgram.Delay(1000);
            LDShapes.AnimationInterval = 0;
            LDShapes.AnimationSet(gifShape, LDShapes.AnimationCount(gifShape) / 3);
            SBProgram.Delay(1000);
            LDShapes.AnimationInterval = 50;
            LDShapes.AnimationPause(gifShape);
            SBProgram.Delay(2000);
            Shapes.HideShape(gifShape);
            LDShapes.AnimationResume(gifShape);
            SBProgram.Delay(2000);
            Shapes.ShowShape(gifShape);
        }
Exemple #25
0
        private void buttonTest_Click(object sender, EventArgs e)
        {
            Primitive shp = Microsoft.SmallBasic.Library.Controls.AddButton("Button", 10, 10);

            LDShapes.ReSize(shp, 100, 100);
            LDShapes.ReSize(shp, 200, 200);

            Primitive xx = LDFastArray.Add();

            LDFastArray.Set(xx, "1 2 3", 24);
            FieldInfo _primitive = typeof(Primitive).GetField("_primitive", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase | BindingFlags.Instance);
            Primitive aa         = "1 23 45";
            string    bb         = (string)_primitive.GetValue(aa);
            Primitive sb         = "1=1\\=\"hello\"\\;2\\=1\\;3\\=2\\;;2=1\\=3\\;2\\=test\\;3\\=3\\;;";
            Primitive arr        = LDFastArray.CreateFromValues(sb);
            Primitive sb1        = LDFastArray.ToArray(arr);

            Primitive a = LDFastArray.Add();

            LDFastArray.Set2D(a, 2, 5, 10);
            LDFastArray.Set2D(a, 2, 2, 20);
            LDFastArray.Set2D(a, 1, 8, 30);
            LDFastArray.Collapse(a);
            Primitive b = LDFastArray.ToArray(a);

            Primitive img = Microsoft.SmallBasic.Library.ImageList.LoadImage("https://upload.wikimedia.org/wikipedia/commons/thumb/d/d6/STS120LaunchHiRes-edit1.jpg/153px-STS120LaunchHiRes-edit1.jpg");
            Primitive x1  = LDImage.Copy(img);

            LDImage.EffectCharcoal(x1);



            Primitive image = LDImage.NewImage(100, 100, "Red");

            LDImage.OpenWorkingImage(image);
            Primitive xml  = LDxml.Open("C:\\Users\\Steve\\Documents\\SmallBasic\\steve\\sample.xml");
            Primitive data = LDxml.ToArray();

            LDxml.FromArray(data);
            LDxml.Save("C:\\Users\\Steve\\Documents\\SmallBasic\\steve\\sample1.xml");
            Primitive txt = Microsoft.SmallBasic.Library.File.ReadContents("C:\\Users\\Steve\\Documents\\SmallBasic\\steve\\txt.txt");

            LDSearch.GetProof(txt, "");
            LDSearch.GetWeb("bill gates");
            return;

            //TextWindow.Show();
            //LDTextWindow.SetColours("Pink", "Orange");
            //TextWindow.WriteLine("Hello World");

            LDPhysics.ReadJson("C:\\Users\\Steve\\Documents\\SmallBasic\\steve\\LDPysics.json", 1, "False", "False", 0, 0);

            LDWaveForm.PlayWave(256, 1000, "0=-1;1=1;5=0;");

            Primitive shape = Shapes.AddRectangle(100, 100);

            LDEffect.Bloom(shape, "");
            Program.Delay(1000);

            LDControls.AddDataView(GraphicsWindow.Width, GraphicsWindow.Height, "1=Hello;2=World;");

            //string _urlTemplate = "https://api.flickr.com/services/rest/?sort=interestingness-desc&safe_search=1&license=1,2,3,4,5,6,7&api_key=";
            //string _picUrlTemplate = "http://farm{0}.static.flickr.com/{1}/{2}_{3}.jpg";
            byte[] array = Convert.FromBase64String("MWY5ZmI5ODE4Mjk2NzAwNTgwYmYzMzQwMjc5MzQ2YjY=");
            //_urlTemplate += Encoding.UTF8.GetString(array, 0, array.Length);
            TextWindow.WriteLine(Encoding.UTF8.GetString(array, 0, array.Length));

            Primitive rtb = LDControls.AddRichTextBox(100, 100);

            LDControls.RichTextBoxSetText(rtb, "Hello", "True");
            LDCall.Compile("C:\\Users\\Steve\\Documents\\SmallBasic\\steve\\testinclude.sb");
            Primitive include = LDCall.Include("C:\\Users\\Steve\\Documents\\SmallBasic\\steve\\testinclude.exe");

            TextWindow.WriteLine(include);

            LDUtilities.FixFlickr();//FCClipboard.GetText
            LDCall.CallAsync("SmallBasicLibrary.dll", "Microsoft.SmallBasic.Library", "Flickr", "GetRandomPicture", "Car");

            string      tempFileName = Path.GetTempFileName();
            Stream      stream       = null;
            Stream      stream2      = null;
            WebResponse webResponse  = null;

            try
            {
                string     url        = "https://a75b9da71f50095fc4dc527d860da4427f274b07.googledrive.com/host/0B9s0FFxEQDb6T3VUdEw3QTJDS1E/efecast00.mp3";
                Uri        uri        = new Uri(url);
                WebRequest webRequest = WebRequest.Create(url);
                webResponse = webRequest.GetResponse();
                stream      = System.IO.File.Open(tempFileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read);
                byte[] buffer = new byte[16384];
                long   num    = webResponse.ContentLength;
                stream2 = webResponse.GetResponseStream();
                int readCount = stream2.Read(buffer, 0, 16384);
                while (readCount > 0L)
                {
                    stream.Write(buffer, 0, readCount);
                    readCount = stream2.Read(buffer, 0, 16384);
                }
            }
            catch (Exception ex)
            {
                TextWindow.WriteLine(ex.Message);
            }
            finally
            {
                if (stream != null)
                {
                    stream.Close();
                }
                if (stream2 != null)
                {
                    stream2.Close();
                }
                if (webResponse != null)
                {
                    webResponse.Close();
                }
            }

            LDGraphicsWindow.SetFontFromFile("C:\\temp\\04b.ttf");
            TextWindow.Show();
            //Primitive source = "class Evaluator { public static function Eval(expr : String) : String { return eval(expr); } }";
            //LDInline.IncludeJScript(source,"","");
            //Primitive result = LDInline.Call("Eval","5+3");
            //TextWindow.WriteLine(result);

            //TextWindow.Hide();
            Primitive x = LDMath.Evaluate("1e6 + 6/4");
            Primitive y = LDMath.Evaluate2("1e6 + 6/4");

            //TextWindow.Hide();
            TextWindow.WriteLine("HERE " + x + " :" + y);

            LDImage.LoadSVG("C:\\temp\\snowtitle.svg");
            TextWindow.WriteLine(LDNetwork.LAN(1000));

            GraphicsWindow.Show();
            LDText.GetWidth("Hello World");

            Primitive server = LDServer.Start("True");

            LDClient.Connect(server, "True");
            LDClient.SendMessage("Hello1");
            LDClient.SendMessage("World1");
            LDServer.Disconnect("Client1");
            LDClient.Connect(server, "True");
            LDClient.SendMessage("Hello3");
            LDClient.SendMessage("World3");

            GraphicsWindow.Show();
            LDGraphicsWindow.FloodFill(200, 100, "#5588ee");
            //Program.Delay(1000000);
            //Primitive languages = LDTranslate.Languages();
            //Primitive indices = SBArray.GetAllIndices(languages);
            //for (int i = 1; i <= SBArray.GetItemCount(languages); i++)
            //{
            //    TextWindow.WriteLine(indices[i] + " : " + languages[indices[i]]);
            //}
            //Primitive result = LDTranslate.Translate("Hello World", "", "de");
            //TextWindow.WriteLine(result);

            //TextWindow.WriteLine(GraphicsWindow.FontName);
            //GraphicsWindow.DrawText(10, 10, "Hello World");
            //Primitive result = LDGraphicsWindow.SetFontFromFile("C:\\Users\\Public\\Documents\\SmallBasic\\steve\\WWFlakes.ttf");
            //TextWindow.WriteLine(GraphicsWindow.FontName);
            //GraphicsWindow.DrawText(10, 50, "Hello World");

            //PrivateFontCollection fntColl = new PrivateFontCollection();
            //fntColl.AddFontFile("C:\\Users\\Public\\Documents\\SmallBasic\\steve\\WWFlakes.ttf");
            //buttonTest.Font = new Font(fntColl.Families[0], 16, FontStyle.Regular);

            //LDDictionary.GetDefinition("Car");
        }
        static void Main(string[] args)
        {
            Primitive[] enemies = new Primitive[10];
            GraphicsWindow.Show();
            var P = Shapes.AddRectangle(100, 20);

            Shapes.Move(P, 0, GraphicsWindow.Height - 20);
            GraphicsWindow.MouseMove += () =>
            {
                Shapes.Move(P, GraphicsWindow.MouseX - 50, GraphicsWindow.Height - 20);
            };
            GraphicsWindow.BrushColor = "yellow";
            var S     = Shapes.AddEllipse(20, 20);
            int x     = 2;
            int y     = 2;
            int stepx = 2;
            int stepy = 2;

            Mouse.HideCursor();
            var F = GraphicsWindow.Width / 10;

            for (int f = 0; f < 10; f++)
            {
                enemies[f] = Shapes.AddRectangle(F, 20);
                Shapes.Move(enemies[f], f * (F), 0);
            }

            Timer.Interval = 1;
            Timer.Tick    += () =>
            {
                Shapes.Move(S, x, y);
                x += stepx;
                y += stepy;
                if (x >= GraphicsWindow.Width - 20)
                {
                    stepx = -stepx;
                }
                //if (y >= GraphicsWindow.Height - 20)
                //{
                //    stepy = -stepy;
                // }
                if (x < 0)
                {
                    stepx = -stepx;
                }
                if (y < 0)
                {
                    stepy = -stepy;
                }
                var mx = GraphicsWindow.MouseX;
                var my = GraphicsWindow.Height - 40;
                if (((x >= mx - 50) && (x <= mx + 50)) && (y >= my))
                {
                    stepy = -stepy;
                }

                if ((x = Shapes.GetLeft(enemies[S])) && (y == Shapes.GetTop(enemies[P])))
                {
                }


                if (y > GraphicsWindow.Height)
                {
                    // Sound.PlayAndWait(" рингтон Sad trombone - Грустный тромбон.mp3");
                    Microsoft.SmallBasic.Library.Program.End();
                }
            };
        }
Exemple #27
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);
            }
        }