What You'll Need

SETUP
Participants

Participants: 1

Devices

Devices: 1

BLOCKS
Start Trail Block Forward Block Rotate Right Block Repeat Block

1. Planning

Let's draw a square! A square is made by 4 lines, like this:

Planning a square

2. Drawing

Now let's draw it with your Capybara. Let's draw the first line by walking forward a few steps. Begin by trying with a number below 10 to ensure the line is neither too long nor too short.

Drawing the first line Drawing the first line

Idea Hint: The order you stack the blocks is very important! Start Trail should be above Forward.

3. Rotation

To make the Capybara draw the second line, first it has to turn. Left or right, it's your choice! Let's use "right" for this example. How much does it have to turn?

Idea The numbers in Rotate Right are angles. So, if the Capybara is facing to the front, it should turn 90°

Rotation angles diagram

So, let's add that rotation. Your code should look like this:

Code for drawing the second line

Now, let's execute that code. This should be the final result:

Final result

4. Repeat

Now that we have 1 side of the square, let's draw all of them by repeating our code 4 times.

Code for drawing the third line

Congratulations! You drew a square.

Final result

Take It Further

Now let's optimize the code, making it more efficient, getting the same outcome with less blocks.

How can we do it? What blocks seem to be repeated? How many times are they repeated?

As you can see, the blocks are repeated four times:

So let's use:

Repeat block example
Repeat

Now you'll have the same square with less coding blocks.

And Beyond!

Now that you know how to draw, walk forward and rotate, let's try one of these drawings! Or imagine new ones and try them!

Block Inventory

EVENTS

When character is touched

MOTION

Forward 10 Rotate Right 120 Rotate Left -200

LOOKS

Start Trail End Trail

CONTROL

Forever Repeat