Turn() public method

public Turn ( float angle ) : void
angle float
return void
Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var len = 100;

            Turtle.Speed = 8;
            Turtle.Turn(90);
            Turtle.Move(len);
            Turtle.TurnRight();
            Turtle.Move(len);
            Turtle.TurnRight();
            Turtle.Move(len);
            Turtle.TurnRight();
            Turtle.Move(len);
            Turtle.Turn(46);
            Turtle.Move(71.98);
            Turtle.Turn(89.6);
            Turtle.Move(71);
            Turtle.PenUp();
            Turtle.Turn(89);
            Turtle.Move(40);
            Turtle.Turn(-45);
            Turtle.PenDown();
            Turtle.Move(40);
            Turtle.TurnRight();
            Turtle.Move(40);
            Turtle.TurnRight();
            Turtle.Move(40);
            Turtle.TurnRight();
            Turtle.Move(40);
            Turtle.PenUp();
            Turtle.Move(500);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var len = 30;


            Turtle.Move(len);
            Turtle.Turn(90);
            Turtle.Move(len);
            Turtle.Turn(90);
            Turtle.Move(len);
            Turtle.Turn(90);
            Turtle.Move(len);
            Turtle.PenUp();
            Turtle.Move(len);
            Turtle.Turn(90);
            Turtle.Move(len * 2);
            Turtle.PenDown();
            Turtle.Turn(90);
            Turtle.Move(len * 3);
            Turtle.Turn(90);
            Turtle.Move(len * 3);
            Turtle.Turn(90);
            Turtle.Move(len * 3);
            Turtle.Turn(90);
            Turtle.Move(len * 3);
            Turtle.Turn(30);
            Turtle.Move(len * 3);
            Turtle.Turn(120);
            Turtle.Move(len * 3);
        }
Exemplo n.º 3
0
        // ЦИКЛЫ. Цикл While.

        // GoodHouse рисует домик и возвращает черепашку в правильное место
        static void GoodHouse(int len)
        {
            // Рисуем тело домика
            Turtle.Turn(90);
            Square(len);

            // Рисуем крышу
            Turtle.Turn(-60);
            Turtle.Move(len);
            Turtle.Turn(120);
            Turtle.Move(len);
            Turtle.Turn(30);

            // Рисуем окошко
            Turtle.PenUp();
            Turtle.Move(2 * len / 3);
            Turtle.Turn(90);
            Turtle.Move(len / 3);
            Turtle.PenDown();
            Square(len / 3);
            Turtle.PenUp();
            Turtle.Move(2 * len / 3);
            Turtle.TurnRight();
            Turtle.Move(2 * len / 3);
            Turtle.PenDown();
        }
Exemplo n.º 4
0
        public void Turtle_ShouldBeSuccess(string moves)
        {
            foreach (var m in moves)
            {
                if (m == 'M')
                {
                    turtle.Move();
                }
                else
                {
                    turtle.Turn(m);
                }
            }

            Assert.Equal("Success", turtle.Status);
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            Turtle.Speed = 9;
            for (int i = 0; i < Cycles; i++)
            {
                Turtle.Move(Dynamic);
                Turtle.TurnRight();
                Turtle.Move(Dynamic);
                Turtle.TurnRight();
                Turtle.Move(Dynamic);
                Turtle.TurnLeft();
                Turtle.Move(Dynamic);
                Turtle.TurnLeft();
            }

            Turtle.Turn(180);
            Turtle.Move(Dynamic);
            Turtle.TurnRight();
            Turtle.Move(Dynamic * 11);
            for (int i = 0; i < 7; i++)
            {
                Turtle.Turn(45);
                Turtle.Move(Dynamic * 2.5);
            }
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            int ang1 = 90;
            int ang2 = 60;
            int ang3 = 120;
            int ang4 = 270;
            int ang5 = 180;

            int len1 = 200;
            int len2 = 50;
            int len3 = 100;

            Turtle.Speed = 5;
            Turtle.Turn(ang5);
            Turtle.PenUp();
            Turtle.Move(len1);
            Turtle.Turn(ang4);
            Turtle.PenDown();
            Turtle.Move(len1);
            Turtle.Turn(ang1);
            Turtle.Move(len1);
            Turtle.Turn(ang1);
            Turtle.Move(len1);
            Turtle.Turn(ang2);
            Turtle.Move(len2);
        }
Exemplo n.º 7
0
        static void Main(String[] args)
        {
            var len = 100;

            Turtle.Speed = 8;

            // Рисуем тело домика

            Turtle.Turn(90);
            Square(len);

            // Рисуем крышу

            Turtle.Turn(-60);
            Turtle.Move(len);
            Turtle.Turn(120);
            Turtle.Move(len);
            Turtle.Turn(30);

            // Рисуем окошко

            Turtle.PenUp();
            Turtle.Move(2 * len / 3);
            Turtle.Turn(90);
            Turtle.Move(len / 3);
            Turtle.PenDown();
            Square(len / 3);
        }
Exemplo n.º 8
0
 static void letterT()
 {
     Turtle.Move(60);
     Turtle.TurnLeft();
     Turtle.Move(30);
     Turtle.Turn(180);
     Turtle.Move(60);
 }
Exemplo n.º 9
0
 static void WriteT()
 {
     Turtle.Move(80);
     Turtle.TurnLeft();
     Turtle.Move(30);
     Turtle.Turn(180);
     Turtle.Move(60);
 }
Exemplo n.º 10
0
 public void drawFigure(int a, int b, int j)
 {
     Turtle.PenUp();
     Turtle.Move(2 * a / 3);
     Turtle.Turn(b);
     Turtle.Move(a / 3);
     Turtle.PenDown();
 }
Exemplo n.º 11
0
 static void printExample2()
 {
     for (int i = 0; i < 6; i++)
     {
         Turtle.Move(100);
         Turtle.Turn(60);
     }
 }
Exemplo n.º 12
0
 public static void WriteL(int longLine)
 {
     Turtle.Angle = 0;
     Turtle.Turn(25);
     Turtle.Move(longLine);
     Turtle.Turn(130);
     Turtle.Move(longLine);
 }
Exemplo n.º 13
0
            public void turtle_draws_TEST()
            {
                const int line_length = 25;

                back_to_start();

                // 'T'
                Turtle.Move(line_length * 2);
                Turtle.TurnLeft();
                Turtle.Move(line_length);
                Turtle.Turn(180);
                Turtle.Move(line_length * 2);

                // 'E'
                Turtle.X     = 250;
                Turtle.Y     = 200;
                Turtle.Angle = 0;
                Turtle.TurnRight();
                Turtle.Move(line_length);
                Turtle.Turn(180);
                Turtle.Move(line_length);
                Turtle.TurnRight();
                Turtle.Move(line_length);
                Turtle.TurnRight();
                Turtle.Move(line_length);
                Turtle.Turn(180);
                Turtle.Move(line_length);
                Turtle.TurnRight();
                Turtle.Move(line_length);
                Turtle.TurnRight();
                Turtle.Move(line_length);

                // 'S'
                Turtle.X     = 300;
                Turtle.Y     = 200;
                Turtle.Angle = 0;
                Turtle.TurnRight();
                Turtle.Move(line_length);
                Turtle.TurnLeft();
                Turtle.Move(line_length);
                Turtle.TurnLeft();
                Turtle.Move(line_length);
                Turtle.TurnRight();
                Turtle.Move(line_length);
                Turtle.TurnRight();
                Turtle.Move(line_length);

                // 'T'
                Turtle.X     = 370;
                Turtle.Y     = 200;
                Turtle.Angle = 0;
                Turtle.Move(line_length * 2);
                Turtle.TurnLeft();
                Turtle.Move(line_length);
                Turtle.Turn(180);
                Turtle.Move(line_length * 2);
            }
Exemplo n.º 14
0
 //Write T
 static void WriteT(int size)
 {
     Turtle.Angle = 0;
     Turtle.Move(size);
     Turtle.TurnLeft();
     Turtle.Move(size / 3);
     Turtle.Turn(180);
     Turtle.Move(size * 2 / 3);
 }
Exemplo n.º 15
0
 public void drawFigure(int a, int b, int j)
 {
     for (var i = 1; i <= j; i++)
     {
         Colorize.Colorized();
         Turtle.Move(a);
         Turtle.Turn(b);
     }
 }
Exemplo n.º 16
0
 public void turtle_draws_a_regular_polygon(int side, int side_length)
 {
     back_to_start();
     for (int i = 0; i < side; i++)
     {
         Turtle.Move(side_length);
         Turtle.Turn(360 / side);
     }
 }
Exemplo n.º 17
0
 public void drawFigure(int a, int b, int j)
 {
     Colorize.Colorized();
     Turtle.Turn(b - 150);
     Turtle.Move(a);
     Turtle.Turn(b + 30);
     Turtle.Move(a);
     Turtle.Turn(b - 60);
 }
Exemplo n.º 18
0
 static void T(int size)
 {
     Turtle.Angle = 0;
     Turtle.Move(size);
     Turtle.Turn(-90);
     Turtle.Move(size / 2);
     Turtle.Turn(180);
     Turtle.Move(size);
 }
Exemplo n.º 19
0
 static void WriteT(int size)
 {
     Turtle.Angle = 0;
     Turtle.Move(60);
     Turtle.TurnLeft();
     Turtle.Move(20);
     Turtle.Turn(180);
     Turtle.Move(40);
 }
Exemplo n.º 20
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            this.Services.AddService(typeof(SpriteBatch), spriteBatch);

            system = new TreeSystem();

            turtle = new Turtle(this);
            turtle.Operations.Add('a', () => turtle.Draw(dist));
            turtle.Operations.Add('b', () => turtle.Draw(dist));
            turtle.Operations.Add('m', () => turtle.Move(dist));
            turtle.Operations.Add('-', () => turtle.Turn(MathHelper.ToRadians(-angle)));
            turtle.Operations.Add('+', () => turtle.Turn(MathHelper.ToRadians(angle)));
            turtle.Operations.Add('[', () => { turtle.Push(); turtle.Turn(MathHelper.ToRadians(-angle)); });
            turtle.Operations.Add(']', () => { turtle.Pop(); turtle.Turn(MathHelper.ToRadians(angle)); });
            turtle.Drawings.Add(system.Get(level, 1));

            base.LoadContent();
        }
Exemplo n.º 21
0
 public void drawFigure(int a, int b, int j)
 {
     Turtle.PenUp();
     Turtle.Turn(2 * b);
     Turtle.Move(a);
     Turtle.TurnRight();
     Turtle.Move(0.32 * a);
     Turtle.Turn(2 * b);
     Turtle.PenDown();
 }
Exemplo n.º 22
0
 public void drawFigure(int a, int b, int j)
 {
     Turtle.PenUp();
     Turtle.TurnLeft();
     Turtle.Move(8.3 * a);
     Turtle.TurnLeft();
     Turtle.Move(2 * a);
     Turtle.Turn(2 * b);
     Turtle.PenDown();
 }
Exemplo n.º 23
0
 private static void WriteT(int size)
 {
     //Буква Т
     Turtle.Angle = 0;
     Turtle.Move(size);
     Turtle.TurnLeft();
     Turtle.Move(size / 3);
     Turtle.Turn(180);
     Turtle.Move(size / 3 * 2);
 }
Exemplo n.º 24
0
 static void Koch(int n)
 {
     Turtle.Turn(30);
     Draw(200, n);
     Turtle.Turn(120);
     Draw(200, n);
     Turtle.Turn(120);
     Draw(200, n);
     Turtle.Turn(120);
 }
Exemplo n.º 25
0
 static void WriteT(int x, int y)
 {
     Turtle.X     = x;
     Turtle.Y     = y;
     Turtle.Angle = 0;
     Turtle.Move(100);
     Turtle.Turn(-90);
     Turtle.Move(50);
     Turtle.Turn(180);
     Turtle.Move(100);
 }
Exemplo n.º 26
0
 static void Main(string[] args)
 {
     Turtle.Speed = 10;
     Turtle.Turn(30);
     Draw(200, 3);
     Turtle.Turn(120);
     Draw(200, 3);
     Turtle.Turn(120);
     Draw(200, 3);
     Turtle.Turn(120);
 }
Exemplo n.º 27
0
 static void CSquare(int len)
 {
     CMove(len);
     Turtle.Turn(90);
     CMove(len);
     Turtle.Turn(90);
     CMove(len);
     Turtle.Turn(90);
     CMove(len);
     Turtle.Turn(90);
 }
Exemplo n.º 28
0
 // ФУНКЦИИ
 // Упрощаем рисование домика, вводя функцию для рисования квадрата
 static void Square(int len)
 {
     Turtle.Move(len);
     Turtle.Turn(90);
     Turtle.Move(len);
     Turtle.Turn(90);
     Turtle.Move(len);
     Turtle.Turn(90);
     Turtle.Move(len);
     Turtle.Turn(90);
 }
Exemplo n.º 29
0
 public static void WriteA(int longLine, int shortLine)
 {
     Turtle.Angle = 0;
     Turtle.Turn(25);
     Turtle.Move(longLine);
     Turtle.Turn(130);
     Turtle.Move(longLine);
     Turtle.Turn(180);
     Turtle.Move(longLine / 2);
     Turtle.Turn(-65);
     Turtle.Move(shortLine);
 }
Exemplo n.º 30
0
    private void Test2(Turtle turtle, double distance)
    {
        double angle = Algorithms.ToRadians(91);

        if (distance > 500)
        {
            return;
        }
        var nextTurtle = turtle.Turn(angle).PenMove(distance).PenToggle();

        Test2(nextTurtle, distance + 1);
    }
Exemplo n.º 31
0
    public void Interpret(out Mesh meshBranches, out Mesh meshLeaves)
    {
        Turtle turtle = new Turtle(Eval(initialWidth));

        foreach (var elem in str){
            switch (elem.symbol){
            case LSElement.LSSymbol.LEAF:
                AddLeaf (turtle.Peek().M,elem.data [0], elem.data [1], turtle.GetDist());
                break;
            case LSElement.LSSymbol.DRAW:
                float movDist = elem.data [0];
                AddCone(turtle.Peek().M, movDist, turtle.GetWidth(), turtle.GetWidth() * elem.data[1], turtle.GetDist());
                turtle.Move(movDist);
                break;
            case LSElement.LSSymbol.TURN:
                turtle.Turn(elem.data[0]);
                break;
            case LSElement.LSSymbol.ROLL:
                turtle.Roll(elem.data[0]);
                break;
            case LSElement.LSSymbol.PUSH_STATE:
                turtle.Push();
                break;
            case LSElement.LSSymbol.POP_STATE:
                turtle.Pop();
                break;
            case LSElement.LSSymbol.WIDTH:
                turtle.SetWidth(elem.data[0]);
                break;
            case LSElement.LSSymbol.GRAVITY:
                turtle.Gravity(elem.data[0]);
                break;
            }
        }

        float max = 0;
        foreach (var u in uvLeafs) {
            max = Mathf.Max (u.x, max);
        }
        for (int i = 0; i < uvs.Count; i++) {
            uvs [i] = new Vector2( uvs [i].x/max,0);
        }
        for (int i = 0; i < uvLeafs.Count; i++) {
            uvLeafs [i] = new Vector2( uvLeafs[i].x/max ,0);
        }

        meshBranches = new Mesh();
        if (vertices.Count >= 65536) {
            Debug.LogError ("Tree - too many verts: "+vertices.Count);
        } else {
            vertCount = vertices.Count;
            meshBranches.vertices = vertices.ToArray ();
            meshBranches.triangles = indices.ToArray ();
            meshBranches.uv = uvs.ToArray ();
            PostprocessMesh (meshBranches);
            //Debug.Log ("vertices "+vertices.Count);
        }
        uvs.Clear();
        vertices.Clear();
        indices.Clear();

        meshLeaves = new Mesh();
        if (verticesLeaf.Count >= 65536) {
            Debug.LogError ("Tree leaves - too many verts: "+verticesLeaf.Count);
        } else {
            vertLeafCount = verticesLeaf.Count;
            meshLeaves.vertices = verticesLeaf.ToArray ();
            meshLeaves.triangles = indicesLeaf.ToArray ();
            meshLeaves.uv = uvLeafs.ToArray ();
            PostprocessMesh (meshLeaves);
        }
        uvLeafs.Clear();
        verticesLeaf.Clear();
        indicesLeaf.Clear();
    }