Browse Source

Add class MinesweeperGame with basic playfield gen.

feature_Minesweeper_Playfield
kfkama 2 years ago
parent
commit
88de22364d
  1. 21
      .gitignore
  2. 36
      src/test/java/Minesweeper/MinesweeperGame.java

21
.gitignore

@ -23,3 +23,24 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar
# Eclipse m2e generated files
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath
# End of https://www.toptal.com/developers/gitignore/api/maven

36
src/test/java/Minesweeper/MinesweeperGame.java

@ -0,0 +1,36 @@
package Minesweeper;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class MinesweeperGame extends JPanel {
public MinesweeperGame(int _playfieldSize) {
this.setSize(600, 600);
setLayout(null);
initPlayfield(_playfieldSize);
}
private void initPlayfield(int _playfieldSize) {
for (int i = 0; i < _playfieldSize; i++) {
for (int j = 0; j < _playfieldSize; j++) {
JButton b = new JButton();
b.setBounds(j * 40, i * 40, 40, 40);
add(b);
}
}
}
public static void main(String[] args) {
JFrame f = new JFrame();
MinesweeperGame ttt = new MinesweeperGame(8);
f.add(ttt);
f.setSize(600, 600);
f.setLayout(null);
f.setVisible(true);
}
}
Loading…
Cancel
Save