public static void reposition(Turtle turtle) { Random generator = new Random(); int posx = generator.nextInt(1000) + 200; int posy = generator.nextInt(500) + 200; turtle.penUp(); turtle.moveTo(posx, posy); turtle.penDown(); }
public static void main(String args[]) { World turtleWorld = new World(); Turtle turtle = new Turtle(turtleWorld); turtle.setPenColor(Color.GREEN); turtle.speed(0); turtle.setPenWidth(25); turtle.penDown(); for (int i = 0; i < 4; i++) { turtle.forward(50); turtle.turnRight(); } }
/* ****************** CHECKLIST ****************************** [x] the size of the scribble MUST be controlled linearly by the value of scale [x] use tu.moveTo() */ boolean scrible(int xPos, int yPos, double scale) { Turtle tu = new Turtle(this); tu.penUp(); tu.moveTo(xPos, yPos); tu.penDown(); int size = (int) scale; tu.penUp(); tu.forward(size / 2); tu.penDown(); tu.turn(-90); for (int i = 0; i < 28; i++) { size = size - 10; tu.forward(size); tu.turn(-90); tu.forward(size); tu.turn(-90); } return true; }
public static void main(String args[]) { World turtleWorld = new World(); Turtle turtle = new Turtle(turtleWorld); turtle.setPenColor(Color.RED); turtle.penDown(); int x = 1; while (true) { turtle.forward(x); x += 1; turtle.turn(90); turtle.forward(x); x += 1; turtle.turn(90); turtle.forward(x); x += 1; turtle.turn(90); turtle.forward(x); x += 1; turtle.turn(90); } }