## Tuesday, July 29, 2014

### Solutions: Art with Pro-Bot - A Dancing Robot

The picture of the Dancing Robot consists of 2 main parts - the body and the head, both of which are squares and can be drawn using Repeat Loops. The interesting part is that the limbs of the robot can also be drawn as part of the Repeat Loop for drawing the body.

Let's look at the code for drawing the body of the robot first. Please keep in mind that depending on the starting point and the direction in which Pro-Bot is facing, you can have different ways of drawing this figure.

Here is one way of drawing it, refer to the figure on the right for the Starting point.

Rpt 4 [
Fd 10       // body + limb = 10 cm
Bk 4
Rt
]

Now, let's try to draw the neck and the head of the robot. Again, the following code is just one of the possible solutions.

Starting from the neck and going up,

Fd 1          // 1 cm long neck
Lt
Fd 1
Rt
Rpt 4 [      // Repeat loop to draw the square for the head
Fd 2
Rt
]

Combining the two pieces of code above, we have the final program to draw our dancing robot:

Rpt 4 [      // Start by drawing the body of the robot
Fd 10
Bk 4
Rt
]
Fd 3         // After drawing the body, get to the start point for drawing the neck
Lt
Fd 1          // Draw the 1 cm long neck
Lt
Fd 1
Rt
Rpt 4 [      // Draw the square for the head
Fd 2
Rt
]