コード例 #1
0
  public void showResult(int count) {
    Image img = null;
    int imageX, imageY = 0;

    // 6 for system tray, and then account for all 4 results
    imageX = 89 - imageBull.getWidth() * 4 - imageInter.getWidth();

    if (gamemode == gameModeBasic) {
      for (int i = 0; i < result[count - 1].length(); i++) {
        switch (result[count - 1].charAt(i)) {
          case 'b':
            img = imageBull;
            break;
          case 'w':
            img = imageCow;
            break;
          case '-':
            img = imageWrong;
            break;
        }
        displayImageAtXY(img, imageX, imageY);
        imageX += img.getWidth();
      }
    } else {
      // number of bulls
      int bulls = Character.digit(result[count - 1].charAt(0), 10);
      int cows = Character.digit(result[count - 1].charAt(2), 10);
      int imageXB = imageX, imageXW = imageX;
      int imageYB = 0, imageYW = 0;

      for (int i = 0; i < bulls; i++) {
        displayImageAtXY(imageBull, imageXB, imageYB);
        imageXB += imageBull.getWidth();
      }

      if (bulls != 0) {
        imageYW = imageBull.getHeight();
      }

      for (int i = 0; i < cows; i++) {
        displayImageAtXY(imageCow, imageXW, imageYW);
        imageXW += imageCow.getWidth();
      }

      if (bulls == 0 && cows == 0) {
        displayImageAtXY(imageWrong, imageX, imageY);
      }
    }
  }
コード例 #2
0
 public void displayImageAtXY(Image img, int x, int y) {
   this.label.draw("", img, x, y, img.getWidth(), img.getHeight(), true);
   this.display.setCurrent(this.label);
 }