diff --git a/.idea/modules.xml b/.idea/modules.xml index 2506f2c..11d6388 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -5,6 +5,7 @@ + diff --git a/ConnectFour/ConnectFour.iml b/ConnectFour/ConnectFour.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/ConnectFour/ConnectFour.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ConnectFour/res/redChip.png b/ConnectFour/res/redChip.png new file mode 100644 index 0000000..d446d3a Binary files /dev/null and b/ConnectFour/res/redChip.png differ diff --git a/ConnectFour/res/yellowChip.png b/ConnectFour/res/yellowChip.png new file mode 100644 index 0000000..f77f0ab Binary files /dev/null and b/ConnectFour/res/yellowChip.png differ diff --git a/ConnectFour/src/Board.java b/ConnectFour/src/Board.java new file mode 100644 index 0000000..26b643e --- /dev/null +++ b/ConnectFour/src/Board.java @@ -0,0 +1,42 @@ +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class Board extends JPanel implements ActionListener { + + private final int DELAY = 15; + private final int BOARD_W = 700; + private final int BOARD_H = 600; + private boolean isInitialized = false; + + private Painter painter; + private Timer timer; + + public Board(){ + initBoard(); + initGame(); + } + + private void initBoard(){ + setPreferredSize(new Dimension(BOARD_W,BOARD_H)); + setBackground(Color.LIGHT_GRAY); + } + + private void initGame(){ + painter = new Painter(); + timer = new Timer(15, this); + timer.start(); + } + + @Override + public void actionPerformed(ActionEvent e) { + repaint(); + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + painter.paintBoard(g, BOARD_W, BOARD_H); + } +} diff --git a/ConnectFour/src/Executor.java b/ConnectFour/src/Executor.java new file mode 100644 index 0000000..f73a6d7 --- /dev/null +++ b/ConnectFour/src/Executor.java @@ -0,0 +1,21 @@ +import javax.swing.*; + +public class Executor extends JFrame { + + public Executor(){ + initUI(); + } + + private void initUI(){ + Board board = new Board(); + add(board); + pack(); + setDefaultCloseOperation(EXIT_ON_CLOSE); + setLocationRelativeTo(null); + } + + public static void main(String[] args) { + Executor executor = new Executor(); + executor.setVisible(true); + } +} diff --git a/ConnectFour/src/Game.java b/ConnectFour/src/Game.java new file mode 100644 index 0000000..f7e8986 --- /dev/null +++ b/ConnectFour/src/Game.java @@ -0,0 +1,2 @@ +public class Game { +} diff --git a/ConnectFour/src/Painter.java b/ConnectFour/src/Painter.java new file mode 100644 index 0000000..03e9250 --- /dev/null +++ b/ConnectFour/src/Painter.java @@ -0,0 +1,64 @@ +import javax.swing.*; +import java.awt.*; +import java.awt.image.ImageObserver; + +public class Painter { + + private int board_w, board_h, tileWidth, tileHeight; + + public Painter(int width, int height){ + board_w = width; + board_h = height; + tileWidth = width/7; + tileHeight = height/6; + } + + private Color holeBlue = new Color(61, 209, 165); + + public void paintBoard(Graphics g){ + Graphics2D g2d = (Graphics2D) g; + g2d.setStroke(new BasicStroke(2)); + for (int i = 0; i < board_w/tileWidth; i++){ + for (int j = 0; j < board_h/tileHeight; j++){ + g2d.setColor(holeBlue); + g2d.fillOval(i * tileWidth + 10, j * tileHeight + 5, tileWidth - 15, tileHeight - 20); + g2d.setColor(Color.BLACK); + g2d.drawOval(i * tileWidth+ 10 , j * tileHeight+5, tileWidth - 15, tileHeight - 20); + } + } + } + + public void paintYellowChip(Graphics g){ + Graphics2D g2d = (Graphics2D) g; + g.drawImage(new redChip().getRedChip(), 0,0, g); + } + + class redChip{ + private ImageIcon imageIcon; + private Image redChip; + private String path = "../res/redChip.png"; + public redChip(){ + imageIcon = new ImageIcon(path); + redChip = imageIcon.getImage().getScaledInstance(tileWidth, tileHeight, 0); + } + + public Image getRedChip() { + return redChip; + } + } + + class yellowChip{ + private ImageIcon imageIcon; + private Image redChip; + private String path = "../res/yellowChip.png"; + public yellowChip(){ + imageIcon = new ImageIcon(path); + redChip = imageIcon.getImage().getScaledInstance(tileWidth, tileHeight, 0); + } + + public Image getRedChip() { + return redChip; + } + } + +} diff --git a/out/production/ConnectFour/Board.class b/out/production/ConnectFour/Board.class new file mode 100644 index 0000000..d567cfd Binary files /dev/null and b/out/production/ConnectFour/Board.class differ diff --git a/out/production/ConnectFour/Executor.class b/out/production/ConnectFour/Executor.class new file mode 100644 index 0000000..72af857 Binary files /dev/null and b/out/production/ConnectFour/Executor.class differ diff --git a/out/production/ConnectFour/Game.class b/out/production/ConnectFour/Game.class new file mode 100644 index 0000000..69e7f7b Binary files /dev/null and b/out/production/ConnectFour/Game.class differ diff --git a/out/production/ConnectFour/Painter.class b/out/production/ConnectFour/Painter.class new file mode 100644 index 0000000..f16f017 Binary files /dev/null and b/out/production/ConnectFour/Painter.class differ diff --git a/out/production/TicTacToe - MinMax/Game.class b/out/production/TicTacToe - MinMax/Game.class index 46d2520..030a1bc 100644 Binary files a/out/production/TicTacToe - MinMax/Game.class and b/out/production/TicTacToe - MinMax/Game.class differ