public void run() {
   double outerCircleDiameter = 2 * OUTER_CIRCLE_RADIUS;
   double middleCircleDiameter = 2 * MIDDLE_CIRCLE_RADIUS;
   double innerCircleDiameter = 2 * INNER_CIRCLE_RADIUS;
   double xOuterCircle = (getWidth() - outerCircleDiameter) / 2;
   double xMiddleCircle = (getWidth() - middleCircleDiameter) / 2;
   double xInnerCircle = (getWidth() - innerCircleDiameter) / 2;
   double yOuterCircle = (getHeight() - outerCircleDiameter) / 2;
   double yMiddleCircle = (getHeight() - middleCircleDiameter) / 2;
   double yInnerCircle = (getHeight() - innerCircleDiameter) / 2;
   GOval outCircle =
       new GOval(xOuterCircle, yOuterCircle, outerCircleDiameter, outerCircleDiameter);
   GOval middleCircle =
       new GOval(xMiddleCircle, yMiddleCircle, middleCircleDiameter, middleCircleDiameter);
   GOval centreCircle =
       new GOval(xInnerCircle, yInnerCircle, innerCircleDiameter, innerCircleDiameter);
   outCircle.setColor(Color.RED);
   middleCircle.setColor(Color.WHITE);
   centreCircle.setColor(Color.RED);
   outCircle.setFilled(true);
   middleCircle.setFilled(true);
   centreCircle.setFilled(true);
   outCircle.setFillColor(Color.RED);
   middleCircle.setFillColor(Color.WHITE);
   centreCircle.setFillColor(Color.RED);
   add(outCircle);
   add(middleCircle);
   add(centreCircle);
 }
 private GOval createFilledCircle(double x, double y, double r, int i) {
   GOval circle = new GOval(x - r, y - r, 2 * r, 2 * r);
   if (i % 2 != 0) {
     circle.setColor(Color.RED);
   } else {
     circle.setColor(Color.WHITE);
   }
   circle.setFilled(true);
   return circle;
 }
 private void buildEye(double x, double y) {
   GOval Eye = new GOval(x, y, eye_radius * 2, eye_radius * 2);
   Eye.setColor(Color.YELLOW);
   Eye.setFilled(true);
   Eye.setFillColor(Color.YELLOW);
   add(Eye);
 }
Exemple #4
0
  /** getReady: Initialize the game */
  private void getReady() {

    // Make up the bricks
    double brickPerWidth =
        (getWidth() - DIST_BRICK_WALL * 2 - DIST_BRICK_BRICK * (NUM_BRICK_ROW - 1)) / NUM_BRICK_ROW;
    double brickPerHeight = BRICK_HEIGHT;
    double x_start = DIST_BRICK_WALL;
    double y_start;
    for (int i = 1; i <= NUM_BRICK_ROW; i++) {
      for (int j = 1; j <= NUM_BRICK_COL; j++) {
        y_start = 50 + (j - 1) * (DIST_BRICK_BRICK + brickPerHeight);
        GRect tmpbrick = new GRect(brickPerWidth, brickPerHeight);
        tmpbrick.setFilled(true);
        add(tmpbrick, x_start, y_start);
      }
      x_start += DIST_BRICK_BRICK + brickPerWidth;
    }

    // Make up the board
    board = new GRect(BOARD_WIDTH, BOARD_HEIGHT);
    board.setFilled(true);
    add(board, (getWidth() - BOARD_WIDTH) / 2, (getHeight() - 30));

    // Place the ball
    ball = new GOval(BALL_RADIUS * 2, BALL_RADIUS * 2);
    ball.setFilled(true);
    ball.setColor(Color.RED);
    add(ball, (getWidth() - BALL_RADIUS * 2) / 2, (getHeight() - 30 - BALL_RADIUS * 2));

    // Set up random generator
    rgen = RandomGenerator.getInstance();

    // Add Listeners
    addMouseListeners();
  }
Exemple #5
0
 public void drawInnerOval() {
   double x = getWidth() / 2.0 - INNER_CIRCLE_WIDTH / 2.0;
   double y = getHeight() / 2.0 - INNER_CIRCLE_WIDTH / 2.0;
   GOval oval = new GOval(x, y, INNER_CIRCLE_WIDTH, INNER_CIRCLE_WIDTH);
   add(oval);
   oval.setFilled(true);
   oval.setFillColor(Color.RED);
   oval.setColor(Color.WHITE);
 }
Exemple #6
0
  public void drawWhiteOval() {

    double x = getWidth() / 2.0 - WHITE_CIRCLE_WIDTH / 2.0;
    double y = getHeight() / 2.0 - WHITE_CIRCLE_WIDTH / 2.0;
    GOval oval = new GOval(x, y, WHITE_CIRCLE_WIDTH, WHITE_CIRCLE_WIDTH);
    add(oval);
    oval.setFilled(true);
    oval.setFillColor(Color.WHITE);
    oval.setColor(Color.WHITE);
  }
 public void run() {
   GOval o = new GOval(40, 40);
   o.setColor(Color.RED);
   o.setFilled(true);
   add(o, 100, 100);
   while (true) {
     pause(WAIT);
     o.move(xMove, yMove);
   }
 }
 public void run() {
   for (int i = 0; i < NCIRCLES; i++) {
     double r = rgen.nextDouble(MIN_RADIUS, MAX_RADIUS);
     double x = rgen.nextDouble(0, getWidth() - 2 * r);
     double y = rgen.nextDouble(0, getHeight() - 2 * r);
     GOval circle = new GOval(x, y, 2 * r, 2 * r);
     circle.setFilled(true);
     circle.setColor(rgen.nextColor());
     add(circle);
   }
 }
Exemple #9
0
 /*Defines and places the Rent state as a circle */
 private void placeRent(int x, int y, int width, int height, Color rentColor) {
   GOval shape = new GOval(x, y, width, height);
   shape.setFilled(true);
   shape.setColor(rentColor);
   add(shape);
 }