Turtlegraphics for Smartphones and Tablets

Bern University of Teacher Education  
HomeStart Online EditorPrintAndroid GamesJava-Online

Serie 9: Touch-events

1)

By touching the display in the draft S9a1 a turtle, that is already able to draw, is created. Change the program so the turtles
a) draw starry formed figures (see drawing a)
b ) draw red coloured 6-sided figures (see drawing b)

To set a red line and fill-colour, the following lines need to be inserted:
t.setPenColor(RED);
To fill the figures, the following line needs to be inserted:
t.fillToPoint(x, y);

c) Use the while(true) -loop to move the turtles on the circle formed blanks.

 

Edit draft with online-editor

 
a)

 

b)

c)

 

2)
 

Draw first 7 vertical and 7 horizontal lines, so that a background of 64 areas is developed. With each touch of the display, a turtle that colours the touched area in red, will be created.

As a draft you may use the following example:

 

Edit draft with online-editor

 

3)
 

Substitute in the draft playgroudPressed() with the method playgroundDragged() to program a freehand-drawing-program.

 

By using the method fillToPoint() filled-figures can be drawn.

Edit draft with online-editor