moved ConnectFour from master to its own branch
This commit is contained in:
@@ -1,11 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="JAVA_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$">
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 21 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 24 KiB |
@@ -1,42 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
public class Game {
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user