Nur die besten Spiele ;3
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.1 KiB

package Minesweeper;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class MinesweeperGame extends JPanel {
private static final long serialVersionUID = 1L;
private static final int WIDTH = 600, HEIGTH = 600;
private static final int CELLSIZE = 40;
private int playfieldSize;
public Cell[][] playfield;
public MinesweeperGame(int _playfieldSize) {
this.setSize(WIDTH, HEIGTH);
playfieldSize = _playfieldSize;
setLayout(null);
initPlayfield();
}
private void initPlayfield() {
playfield = new Cell[playfieldSize][playfieldSize];
for (int i = 0; i < playfieldSize; i++) {
for (int j = 0; j < playfieldSize; j++) {
Cell c = new Cell(CellType.Number);
c.setBounds(j * CELLSIZE + (WIDTH / 2 - playfieldSize * CELLSIZE / 2), i * CELLSIZE + (HEIGTH / 2 - playfieldSize * CELLSIZE / 2), CELLSIZE,
CELLSIZE);
add(c);
}
}
}
public static void main(String[] args) {
JFrame f = new JFrame();
MinesweeperGame ttt = new MinesweeperGame(8);
f.add(ttt);
f.setSize(WIDTH, HEIGTH);
f.setLayout(null);
f.setVisible(true);
}
}