Turtlegraphics with Java
HomeAufgabenDruckenJava-Online

Serie 8: Multiple Turtles

 

1)
Two Turtles take it in turns to draw steps.

 

2)

Green, red and blue turtles draw the adjacent figures

- The basic figure has the following form:

- Draw the following zig-zag pattern with a for structure:

- The pattern can be filled using the fillToHorizontal() method


3)

 

Two Turtles take it in turns to draw squares. The first Turtle with a blue colour, the second Turtle with a red colour.

 

4) The squares can be filled using the fill(x, y) method, whereby the point (x, y) must be inside the square. You can find out the current position of the turtle using the getX() and getY() methods.  

5)

Two Turtles move with random distances and random angles
e.g.: left(-180 + 360 * Math.random()). If they come too close to each other, a sound is emitted, the two Turtles delete the tracks and then move randomly again. To prevent the Turtles from disappearing from the Turtle window, you can use the wrap() method.

An endless while loop can be used so that the Turtles can run for as long as required:

while (true)
{

}