コード例 #1
0
ファイル: MineCanvas.java プロジェクト: panyam/bfpmine
  /** Paint it. */
  public void paint(Graphics g) {
    Dimension d = getSize();
    if (!inited || buff == null || d.width != buffSize.width || d.height != buffSize.height) {
      buffSize.width = d.width;
      buffSize.height = d.height;
      buff = createImage(d.width + 4, d.height + 4);
      if (buff == null) return;
      buffG = buff.getGraphics();
      inited = true;
    }

    buffG.setColor(Color.lightGray);
    buffG.fillRect(0, 0, prefSize.width, prefSize.height);
    PressedRect(buffG, 0, 0, prefSize.width - 2, prefSize.height - 2);

    buffG.setColor(Color.lightGray);
    buffG.fillRect(0, 0, prefSize.width + 2, prefSize.height + 2);
    if (!gameover) if ((gameover = is_game_over())) end_game();
    for (int i = 0; i < rows; i++) {
      for (int j = 0; j < cols; j++) {
        drawBlock(buffG, i, j, status(i, j));
      }
    }
    // PressedRect(buffG,0,0,prefSize.width + 2,prefSize.height + 2);
    if (buff != null) g.drawImage(buff, 0, 0, null);
  }
コード例 #2
0
ファイル: MineCanvas.java プロジェクト: panyam/bfpmine
 public void restart(int rows, int cols, int nummines) {
   this.rows = rows;
   this.cols = cols;
   this.nummines = nummines;
   prefSize.width = cols * wt;
   prefSize.height = rows * ht;
   minerowlist = new int[nummines];
   minecollist = new int[nummines];
   restart();
 }
コード例 #3
0
ファイル: MineCanvas.java プロジェクト: panyam/bfpmine
 public Dimension getPreferredSize() {
   prefSize.width = 4 + cols * ht;
   prefSize.height = 4 + rows * ht;
   return prefSize;
 }