diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6b468b6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.class diff --git a/README b/README index c4fae44..eccc331 100644 --- a/README +++ b/README @@ -5,3 +5,5 @@ fast enough for complex algorithms and complex games. Please look at the INSTALL file for installation tips. Please look at the HACKER file for ideas for developers. + +Also under Linux may use ./rebuild.sh && ./run.sh to build&run game inplace diff --git a/rebuild.sh b/rebuild.sh new file mode 100755 index 0000000..397f7b4 --- /dev/null +++ b/rebuild.sh @@ -0,0 +1,4 @@ +#!/bin/sh +find -type f -name *.class -delete +javac -cp "$(pwd)/src:$(pwd)/res" src/friendless/games/filler/Filler.java +javac -cp "$(pwd)/src:$(pwd)/res" src/friendless/games/filler/player/*.java diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..aaed901 --- /dev/null +++ b/run.sh @@ -0,0 +1,2 @@ +#!/bin/sh +java -cp "$(pwd)/src:$(pwd)/res" friendless/games/filler/Filler diff --git a/src/friendless/games/filler/FillerBoard.java b/src/friendless/games/filler/FillerBoard.java index f44ec2b..c0bbbd1 100644 --- a/src/friendless/games/filler/FillerBoard.java +++ b/src/friendless/games/filler/FillerBoard.java @@ -16,27 +16,38 @@ import java.awt.*; import java.awt.image.BufferedImage; +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; import java.io.File; import java.io.IOException; import java.text.MessageFormat; import javax.imageio.ImageIO; import javax.swing.*; + /** * A graphical component which is the array of hexagons. * * @author John Farrell */ -public class FillerBoard extends JComponent { +public class FillerBoard extends JComponent implements ComponentListener { /** the pixel coordinates of the hexes */ - static Point[] topLefts, botRights; - private static final int SIZE = 7; + Point[] topLefts, botRights; + public final static int MIN_SIZE = 5; + int count; + int SIZE = MIN_SIZE; + Dimension dim; - static { + public void updateSize() { + Dimension mySize = getSize(); + int dX = FillerSettings.COLUMNS > 0 ? mySize.width / (FillerSettings.COLUMNS + 1) : MIN_SIZE; + int dY = FillerSettings.ROWS > 0 ? mySize.height / FillerSettings.ROWS / 4 : MIN_SIZE; +// System.out.printf("width=%d height=%d cols=%d rows=%d dx=%d dy=%d\n", +// mySize.width, mySize.height, FillerSettings.COLUMNS, FillerSettings.ROWS, dX, dY); + SIZE = (dX < dY) ? dX : dY; + if (SIZE < MIN_SIZE) { SIZE = MIN_SIZE; } int size = FillerSettings.SIZE; - topLefts = new Point[size]; - botRights = new Point[size]; - for (int i=0; i