Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

Turtle Graphics [4/12]

Let's try to draw a house.

The first three lines are akin to drawing a square. Now the roof. First, the command RT(180) turns the pen into the opposite direction.

A shape that makes up the roof is a triangle. If the lines of the roof are to be the same length as the other lines, then the triangle is equilateral. Equailateral triangles have all sides of equal lenght and inner angles equal to 60 degrees. Therefore, we turn the pen by 60 degrees and draw a line of length 200.

For the second part of the roof, we have to make another turn. The inner angle of an equilateral triangle is 60 degrees, which makes the outer angle equal to 120 degrees, because inner angle and outer angle must sum up to 180 degrees. So, we turn 120 degrees to the right.

Unfortunately, the drawing is out of bounds. To correct this, uncomment the SETPOS command at the top.

Loading...