-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMinerMain.java
56 lines (39 loc) · 1.5 KB
/
MinerMain.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package ru.lesson.lessons.miner.v3;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.*;
import ru.lesson.lessons.miner.v3.MinerBoard;
import ru.lesson.lessons.miner.v3.MinerBoardGenerator;
/**
* Created by user1 on 01.03.2017.
*/
// ãëàâíûé êëàññ äëÿ èãðû "Ñàïåð"
public class MinerMain {
private static final JPanel controlPanel = new JPanel();
private static final MinerBoard board = new MinerBoard();
private static final MinerBoardGenerator minerBoardGenerator = new MinerBoardGenerator();
public static void main(String[] arg) {
new MinerMain().run();
}
public void run() {
final JFrame frame = new JFrame();
frame.setTitle("Miner");
frame.setLayout(new BorderLayout());
frame.setSize(500, 500);
frame.add(board, BorderLayout.CENTER);
frame.add(controlPanel, BorderLayout.PAGE_END);
controlPanel.setLayout(new FlowLayout());
final JButton generate = new JButton("Start game");
generate.addActionListener(new GenerateListener());
controlPanel.add(generate);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
public class GenerateListener implements ActionListener {
public void actionPerformed(ActionEvent a) {
board.drawBoard(minerBoardGenerator.generate(3,3,20)); // ñîçäàåì ìàññèâ ÿ÷ååê 3x3 è çàïóñêàåì èãðó
System.out.println("Game started");
}
}
}