Turtlegraphics with Java
HomeAufgabenDruckenJava-Online

Serie 10: Events


1.

When any key is pressed, 1, 2, 3, 4, 5 or 6 dots should be drawn at random.

The following example from the tutorial is suitable as a template:

$host?>/online/tuexamples/Tu23.html" target="_blank">Edit example in the online editor

       
2.

Each time the mouse is clicked, a new turtle should draw a small red square at the mouse position.

 

       
3.

Each time the mouse is clicked, a new turtle is created at the position of the mouse click. This moves horizontally. When it reaches the edge of the frame, it rotates 180° and moves back and forth endlessly.

 

 
       
4.

Use the standard Java event methods to draw a star figure with a mouse click. This time only one turtle is used, which draws one star after the other.

 

 
       
5.

Programme a Turtle race:
The two Turtles start at the bottom of the window. The forward distance is randomly 10, 20, 30, 40, 50 or 60. When the left mouse button is pressed, the red Turtle moves, when the right mouse button is clicked, the blue Turtle moves. The turtle that reaches the finish line first wins.