示例#1
0
  public void drawGame() {
    StdDraw.clear(StdDraw.GRAY);

    // Set Color
    StdDraw.setPenColor(StdDraw.YELLOW);
    // Set Font
    setFont(new Font("SansSerif", Font.PLAIN, 32));
    // X, Y, String, rotation degree
    // Write String
    this.text(1 - 0.3, 1 - 0.1, blockP.x + ", " + blockP.y, 0);
    // Set Color
    StdDraw.setPenColor(StdDraw.ORANGE);
    // Set Font
    setFont(new Font("SansSerif", Font.PLAIN, 50));
    // Write String
    this.text(1 - 0.3, 1 - 0.3, "START!", 20);

    StdDraw.setPenColor(StdDraw.BLACK);

    for (int i = 0; i < map.length; i++) {
      for (int j = 0; j < map[i].length; j++) {
        if (map[i][j] > 0) {
          Point2D vLoc = map2Visual(i, j);
          System.out.println(i + ", " + j + ", " + vLoc);
          StdDraw.filledCircle(vLoc.getX(), vLoc.getY(), radius);
        }
      }
    }
  }
示例#2
0
  /**
   * hits a point to add them in active object queue.
   *
   * @param a_single when it is true, the method returns after finding the first hit.
   */
  public boolean hit(Point2D a_point, boolean a_isAppend, boolean a_isSelectOnlyOne) {
    if (a_point == null) {
      return false;
    } // if

    Rectangle2D rect = new Rectangle2D.Double(a_point.getX(), a_point.getY(), 1.0, 1.0);
    return hit(rect, a_isAppend, a_isSelectOnlyOne);
  }