Exemplo n.º 1
0
        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++;
                }
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            GraphicsWindow.KeyDown += GraphicsWindow_KeyDown;
            Turtle.PenUp();

            var eat = Shapes.AddEllipse(10, 10);
            int x   = 200;
            int y   = 200;

            Shapes.Move(eat, x, y);

            Random rand = new Random();

            while (true)
            {
                Turtle.Move(5);
                if ((Turtle.X >= x && Turtle.X <= x + 10) && (Turtle.Y >= y && Turtle.Y <= y + 10))
                {
                    x = rand.Next(10, GraphicsWindow.Width);
                    y = rand.Next(10, GraphicsWindow.Height);
                    Shapes.Move(eat, x, y);
                    Turtle.Speed++;
                }
            }
        }
Exemplo n.º 3
0
        private void buttonInstances_Click(object sender, EventArgs e)
        {
            //GraphicsWindow.Show();
            Primitive win = new Primitive();

            for (int i = 0; i < 3; i++)
            {
                win[i] = LDWindows.Create();
                GraphicsWindow.Title = i.ToString();
                //Shapes.AddEllipse(100, 100);
            }
            LDWindows.CurrentID = win[0];
            Primitive ball = Shapes.AddEllipse(100, 100);

            LDWindows.CurrentID = win[1];
            Shapes.AddEllipse(100, 100);
            GraphicsWindow.BackgroundColor = "Red";
            GraphicsWindow.Hide();
            LDWindows.CurrentID = 0;
            GraphicsWindow.Show();
            LDWindows.CurrentID = win[0];
            Shapes.Move(ball, 200, 200);
            LDWindows.CurrentID = 0;
            Shapes.Move(ball, 300, 300);
            //LDWindow.Hide(win[0]);
            //LDWindow.Close(win[1]);
            //Program.Delay(5000);
            //LDWindow.Hide(win[2]);
        }
Exemplo n.º 4
0
        private void buttonColours_Click(object sender, EventArgs e)
        {
            Primitive col = LDColours.SetOpacity("Orange", 100);

            TextWindow.WriteLine(col);
            TextWindow.WriteLine(LDColours.GetOpacity(col));
            TextWindow.WriteLine(LDColours.GetRed(col));
            TextWindow.WriteLine(LDColours.GetGreen(col));
            TextWindow.WriteLine(LDColours.GetBlue(col));

            TextWindow.WriteLine(LDColours.GetHue(col));
            TextWindow.WriteLine(LDColours.GetSaturation(col));
            TextWindow.WriteLine(LDColours.GetLightness(col));
            col = LDColours.HSLtoRGB(LDColours.GetHue(col), LDColours.GetSaturation(col), LDColours.GetLightness(col));
            TextWindow.WriteLine(col);

            for (int i = 0; i < 360; i++)
            {
                GraphicsWindow.BackgroundColor = LDColours.HSLtoRGB(i, 1, 0.5);
                SBProgram.Delay(20);
            }
            LDUtilities.PauseUpdates();
            GraphicsWindow.PenWidth = 0;
            Primitive colour = "Blue";
            Primitive ball   = Shapes.AddEllipse(300, 300);

            Shapes.Move(ball, GraphicsWindow.Width / 2 - 150, GraphicsWindow.Height / 2 - 150);
            LDShapes.BrushColour(ball, LDColours.SetOpacity(colour, 0));
            LDUtilities.ResumeUpdates();
            for (int i = 0; i < 255; i++)
            {
                LDShapes.BrushColour(ball, LDColours.SetOpacity(colour, i));
                SBProgram.Delay(10);
            }
        }
Exemplo n.º 5
0
        private void buttonDialogs_Click(object sender, EventArgs e)
        {
            int i;

            GraphicsWindow.Show();
            Primitive items  = "";
            Primitive images = "";

            for (i = 1; i <= 5; i++)
            {
                items[i]  = "Item " + i;
                images[i] = "C:\temp\test.jpg";
            }
            LDDialogs.AddRightClickMenu(items, images);

            TextWindow.WriteLine(System.Windows.Media.RenderCapability.Tier >> 16);
            Primitive a1 = LDArray.Create(1000);

            Shapes.AddEllipse(50, 50);
            FormPropertyGrid grid = new FormPropertyGrid();

            grid.Display("_mainCanvas");
            Primitive properties = grid.GetProperties("_mainCanvas");

            for (i = 1; i <= SBArray.GetItemCount(properties); i++)
            {
                TextWindow.WriteLine(properties[i]);
            }

            grid.SetProperty("_mainCanvas.Children.Ellipse1.Opacity", 0.5);

            Primitive font     = LDDialogs.Font("");
            Primitive font2    = LDDialogs.Font(font);
            Primitive fileName = LDDialogs.OpenFile("Small Basic File (*.sb) |*.sb", "");

            LDUtilities.Version();
            GraphicsWindow.Show();
            TextWindow.WriteLine(LDDialogs.Calendar(LDDateTime.Add(LDDateTime.Now(), 7))); //Now + 7 days
            //LDUtilities.PauseUpdates();
            LDDialogs.Wait("Please wait for a few seconds while I draw something...", LDColours.SetOpacity(LDColours.Violet, 200));
            double start = Clock.ElapsedMilliseconds;

            i = 1;
            while (Clock.ElapsedMilliseconds < start + 5000)
            {
                Primitive ball = Shapes.AddEllipse(20, 20);
                Shapes.Move(ball, SBMath.GetRandomNumber(GraphicsWindow.Width) - 10, SBMath.GetRandomNumber(GraphicsWindow.Height) - 10);
                LDDialogs.ToolTip(ball, "Ball " + i++);
                SBProgram.Delay(100);
            }
            //LDUtilities.ResumeUpdates();
            LDDialogs.EndWait();
        }
Exemplo n.º 6
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;
                    }
                }
            };
        }
Exemplo n.º 7
0
        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();
                }
            };
        }
Exemplo n.º 8
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);
        }