Thursday, November 02, 2006

Week 4 - Logo and Drawing

Drawing on the Battle Botz site - click the link and use the "test" area.

Using FMS Logo (this should be on the lab computers). User manual is here.

Basic Logo Commands (which can be used in the command line or in a program)
FD # (Moves the turtle forward # steps, e.g. FD 10)
RT # (Turns the turtle right # degrees, e.g. RT 90)
Penup (Stops the turtle from drawing)
Pendown (Starts the turtle drawing)
Home (Returns the turtle to the starting position in the middle of the screen)
CS (Clear Screen erases the drawing).

A Simple Program (write in the editor)

to square
repeat 4[FD 10 RT 90]
end

to spiral
repeat 36[square rt 10]
end

In the command line type square or type spiral. Note the programs square or spiral may have any name that you like.

A program with variables

to square_size :side
repeat 4[FD :side RT 90]]
end

In the command line type square_size "5 or square_size "8

Copy the following into "edsall"

to square :size
repeat 4[fd :size rt 90]
end

to triangle :size
repeat 3[fd :size rt 120]
end

to circle :size
repeat 360[fd :size rt 1]
end

to polygon :sides :size
repeat :sides[fd :size rt (360/:sides)]
end

to spiral :sides :size
repeat 36[polygon “:sides “:size rt 10]
end

Save and Exit
On the command line write polygon "5 "10
Does this give a pentagon?

No comments: