Turtle Academy just had a system upgrade if you experience any issues. Please try to hard refresh using CTRL + F5.

If the issues continue please contact us.

24.Code reuse

Many times we might want to use a Square in our program, but it can be frustrating to define it every time.
Define a square function that gets :size as parameter and using rt 90 to turn
Now let's create a triangle function that we will use in our program
Define a triangle getting :size as parameter and turning using rt 120
Let's write the following command (it's a very simple house).
Write the command cs square 50 fd 50 rt 30 triangle 50
Now we open a new program and we want to use the triangle and square to create a house ... Well there will be a problem since the commands are not define by the Turtle so we will have to redefine exactly the same pretty frustrating ahh...
Let's clear the screen by writing cs
Luckily we have a way to reuse our code. We can define a program that include our functions and then include it in our program. In this case we created a program which has the id 45865 ( when creating a program you might see the Id in the URL). The include command works as follow: include ID (ID is the program id we include etc 1234).
Le'ts include program 45865
We already included the program in the last step now let's try to call triangle and square to create a house.
Write the command: cs square 50 fd 50 rt 30 triangle 50
TurtleAcademy learn programming for freeYour browser is not supporting canvasWe recomand you to use Chrome or Firefox browsers