示例#1
0
 public void draw() {
   switch (n) {
     case 0:
     case 1:
     case 2:
     case 3:
       // case 4:
       // case 5:
       x += 5;
       n++;
       break;
     case 4:
     case 5:
     case 6:
     case 7:
       //		case 8:
       //		case 9:
       //		case 10:
       x -= 5;
       n++;
       break;
     case 8:
       n = 0;
       break;
   }
   if (visible) {
     parent.image(img, x, y);
   }
 }
示例#2
0
  public void drawGrid(int[][] f) {
    int piece;
    int numcols = f[0].length;
    int numrows = f.length;

    for (int i = 0; i < numcols; i++) {
      for (int j = 0; j < numrows; j++) {
        piece = f[i][j];
        if (piece == 1) {
          p.image(piece1, x + i * dx + 1, y + j * dy + 1, dx - 1, dy - 1);
        } else if (piece == 2) {
          p.image(piece2, x + i * dx + 1, y + j * dy + 1, dx - 1, dy - 1);
        } else {
          p.fill(EMPTY_COLOR);
          p.rect(x + i * dx, y + j * dy, dx, dy);
        }
      }
    }
  }
示例#3
0
 public void draw() {
   if (dirtyTree) render(tree);
   p.background(255);
   if (g != null) p.image(g, x, y, w, h);
   if (p.mousePressed) {
     if (p.mouseButton == PApplet.LEFT) pan(p.mouseX - p.pmouseX, p.mouseY - p.pmouseY);
     if (p.mouseButton == PApplet.RIGHT) zoom(p.pmouseY - p.mouseY);
   }
   if (p.keyPressed) {
     if (p.key == '1' && keyReady) captureFullGraphic("temp.png");
     if (p.key == '2' && keyReady) captureScreenshot("temp.png");
     if (p.key == '0' && keyReady) resetView();
     keyReady = false;
   } else keyReady = true;
 }
示例#4
0
 public void drawwithdown() {
   switch (n) {
     case 0:
     case 1:
       x += wid / 3;
       n++;
       break;
     case 2:
     case 3:
       x -= wid / 3;
       n++;
       break;
     case 4:
       n = 0;
       y += hgt / 2;
       break;
   }
   if (visible) {
     parent.image(img, x, y, width / 10, height / 15);
   }
 }