loopy-circles.txt (560B)
1 Canvas c = Canvas.getCanvas(); 2 Circle circle1 = new Circle(); 3 int width = c.getWidth(); 4 int height = c.getHeight(); 5 int xPos = 0; 6 int currentXPos = 0; 7 int yPos = 0; 8 int currentYPos = 0; 9 java.util.Random rand = new java.util.Random(); 10 circle1.makeVisible(); 11 12 int count = 0; 13 14 while (count < 5){ 15 xPos = rand.nextInt(width); 16 yPos = rand.nextInt(height); 17 currentXPos = circle1.getXCoord(); 18 currentYPos = circle1.getYCoord(); 19 circle1.slowMoveHorizontal(xPos - currentXPos); 20 circle1.slowMoveVertical(yPos - currentYPos); 21 22 count = count + 1; 23 } 24