示例#1
0
  public void run() {
    MOVE_PREV = MOVE_DOWN;

    System.out.println("INIT!");
    map = new int[mapX][mapY];

    for (int i = 0; i < map.length; i++) {
      for (int j = 0; j < map[i].length; j++) {
        map[i][j] = 0;
      }
    }
    map[blockP.x][blockP.y] = 1;
    //    	map[0][20] = 1;

    StdDraw.setXscale(-1.0, 1.0);
    StdDraw.setYscale(-1.0, 1.0);

    // initial values

    // double vx = 0.015, vy = 0.023;     // velocity

    // main animation loop
    while (true) {

      drawGame();
      try {
        Thread.sleep(100);
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      movePrev();
    }
  }
示例#2
0
  /** Test client. */
  public static void main(String[] args) {

    // set the scale of the coordinate system
    StdDraw.setXscale(0, 10);
    StdDraw.setYscale(0, 10);

    // Draw line
    StdDraw.line(1, 1, 8, 8);

    // Draw square
    StdDraw.setPenColor(StdDraw.RED);
    StdDraw.setPenRadius(.01);
    StdDraw.square(3, 3, 2);

    // Draw filled Square
    StdDraw.setPenColor(StdDraw.BLUE);
    StdDraw.filledSquare(5, 8, 2);

    // Draw Circle
    StdDraw.setPenColor(StdDraw.BLACK);
    StdDraw.setPenRadius();
    StdDraw.circle(5, 5, 2);

    // text
    StdDraw.setPenColor(StdDraw.BLACK);
    StdDraw.text(6, 1, "black text");
  }
示例#3
0
 public void draw() {
   StdDraw.setPenColor(Color.BLACK);
   StdDraw.setPenRadius(0.005);
   StdDraw.setYscale(-1, root.height + 2);
   StdDraw.setXscale(-1, root.N + 1);
   TreePosition rootTree = draw(root, 0, root.height);
   drawNode(rootTree, root);
 }