import Myro.*; /** * Write a description of class circleAnimation here. * * @author (your name) * @version (a version number or a date) */ public class circleAnimation { private SimpleCircle leftEye; private SimpleCircle rightEye; public void main(){ leftEye = new SimpleCircle(); rightEye = new SimpleCircle(); rightEye.moveHorizontal(20); System.out.println("----"); //myCircle.moveHorizontal(10); //make the circle move with a for loop int j=0; int randX, randY; while (j<50) { j++; randX = MyroUtils.randomInt(-2,1); randY = MyroUtils.randomInt(-2,1); for (int i=0; i<10; i++) { if (getXPosition() <= 20 && randX < 0) { randX = -randX; } moveFaceHorizontal(randX); /* //move Horizontal as long as it doesn't push us off the left of the screen if (!(getXPosition() > 0 && randX > 0)) { moveFaceHorizontal(randX); } else { moveFaceHorizontal(1); } */ if (getYPosition() <= 0 && randY < 0) { randY = -randY; } moveFaceVertical(randY); /* if (!(getYPosition() > 0 && randY > 0)) { moveFaceVertical(randY); } else { moveFaceVertical(1); } */ System.out.println(getXPosition() + ", " + getYPosition()); } } /* //move circle there and back with 2 for loops for (int i=0; i<50; i++) { myCircle.moveHorizontal(-4); } int integer=4; //move circle there and back with 1 for loop for (int i=0; i<50; i++) { if (i==25) { integer = -integer; } myCircle.moveVertical(integer); } */ } public void moveFaceHorizontal(int distance) { rightEye.moveHorizontal(distance); leftEye.moveHorizontal(distance); } public void moveFaceVertical(int distance) { rightEye.moveVertical(distance); leftEye.moveVertical(distance); } public int getXPosition() { int value = rightEye.getXPosition(); return value; } public int getYPosition() { int value = rightEye.getYPosition(); return value; } }