Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 2 commits
  • 19 files changed
  • 0 commit comments
  • 1 contributor
View
15 src/com/example/kindle/winningfour/boardgame/GameController.java
@@ -96,6 +96,7 @@ public void run()
};
this.clock.reset(clockTask, (new OptionsFactory()).createGameClockTimeout());
+ this.gameView.setProgressTicks(0);
this.repaint();
@@ -319,14 +320,20 @@ public void addStateListener(final IGameStateListener listener)
public void startTimer()
{
- this.gameView.setProgressTicks(0);
- this.clock.start();
+ if (this.clock.getTimeout() != 0)
+ {
+ this.gameView.setProgressTicks(0);
+ this.clock.start();
+ }
}
public void stopTimer()
{
- this.clock.stop();
- this.gameView.setProgressTicks(GameClock.RESOLUTION);
+ if (this.clock.getTimeout() != 0)
+ {
+ this.clock.stop();
+ this.gameView.setProgressTicks(GameClock.RESOLUTION);
+ }
}
public void destroy()
View
10 src/com/example/kindle/winningfour/boardgame/GameView.java
@@ -46,7 +46,10 @@ public void doLayout()
{
App.log("GameView::doLayout for " + this.getSize());
final Dimension size = this.getSize();
-
+
+ // TODO: layout reset
+ this.layout = AppResources.getSkin().getLayout(size);
+
if (this.layoutSize != null && this.layoutSize.equals(size))
{
App.log("GameView::doLayout early exit (same size)");
@@ -54,14 +57,13 @@ public void doLayout()
}
this.layoutSize = size;
- this.layout = AppResources.getSkin().getLayout(size);
this.gameSelector.setBounds(size.width/2 - this.layout.pieceSizeX/2, this.layout.selectorY,
this.layout.pieceSizeX, this.layout.pieceSizeX);
this.gameSelector.setImage(AppResources.getImage("selector.png", this,
this.layout.pieceSizeX, this.layout.pieceSizeX));
- this.gameSelector.setLocation(this.layout.boardLeftTopX +
+ this.gameSelector.setLocation(this.layout.boardRect.x +
this.selectedRow*(this.layout.pieceSizeX + this.layout.pieceGapX),
this.layout.selectorY);
@@ -84,7 +86,7 @@ public void paint(Graphics g)
{
App.log("GameView::paint in clipBounds " + g.getClipBounds());
- this.gameSelector.setLocation(this.layout.boardLeftTopX +
+ this.gameSelector.setLocation(this.layout.boardRect.x +
this.selectedRow*(this.layout.pieceSizeX + this.layout.pieceGapX),
this.layout.selectorY);
View
153 src/com/example/kindle/winningfour/boardgame/rules/ClassicRules.java
@@ -1,6 +1,7 @@
package com.example.kindle.winningfour.boardgame.rules;
import java.util.ArrayList;
+import java.util.Iterator;
import com.example.kindle.boardgame.GameEvent;
import com.example.kindle.boardgame.IBoard2D;
@@ -21,10 +22,22 @@
public static final int MAX_WIDTH = 10;
public static final int MAX_HEIGHT = 7;
+ public static final int W_MAX = 10000;
+ public static final int W_FALLOFF = 1;
+
+ public static final int W_DRAW = 1;
+ public static final int W_THREAT_TWO = 2;
+ public static final int W_THREAT_THREE = 5;
+ public static final int W_THREAT_ZUG = 3;
+ public static final int W_WIN = W_MAX;
+
+ public static final int B_MAJOR = 2;
+ public static final int B_FORK = 2;
+
public ClassicRules()
{
}
-
+
public void afterPlayerTurn(final IBoard2D board)
{
int gameEvent = this.checkGameEvent(board);
@@ -34,7 +47,7 @@ public void afterPlayerTurn(final IBoard2D board)
this.gameEventListener.onGameEvent(gameEvent);
}
}
-
+
public int checkGameEvent(final IBoard2D board)
{
int result = GameEvent.CONTINUE;
@@ -45,18 +58,15 @@ public int checkGameEvent(final IBoard2D board)
IPosition2D pos = (IPosition2D) turn.getPosition().clone();
int max = 0;
- int counts[] = new int[4];
- int incs[][] = {{1, 0}, {0, 1}, {1, 1}, {1, -1}};
- for (int c = 0; c < incs.length; c++)
- {
- counts[c] = this.countInRow(board, p, pos, incs[c][0], incs[c][1]);
- }
+ ArrayList threats = this.walk(board, p, pos);
- for(int i = 0; i < counts.length; i++)
+ Iterator iter = threats.iterator();
+ while(iter.hasNext())
{
- if (counts[i] > max)
+ Threat threat = (Threat) iter.next();
+ if (threat.count > max)
{
- max = counts[i];
+ max = threat.count;
}
}
@@ -74,16 +84,40 @@ else if (board.getTurnsCount() >= board.getWidth() * board.getHeight())
return result;
}
- private int countInRow(final IBoard2D board, final IPlayer player, final IPosition2D pos, int incx, int incy)
+ private ArrayList walk(final IBoard2D board, final IPlayer player, final IPosition2D pos)
{
- return this.walk(board, player, pos, incx, incy) +
- this.walk(board, player, pos, -incx, -incy) - 1;
+ ArrayList threats = new ArrayList();
+
+ int incs[][] = {{1, 0}, {0, 1}, {1, 1}, {1, -1}};
+ for (int c = 0; c < incs.length; c++)
+ {
+ Threat threat = this.countInRow(board, player, pos, incs[c][0], incs[c][1]);
+ if (threat.count > 1)
+ {
+ threats.add(threat);
+ }
+ }
+
+ return threats;
+ }
+
+ private Threat countInRow(final IBoard2D board, final IPlayer player, final IPosition2D pos, int incx, int incy)
+ {
+ Threat left = this.countInRowOneDir(board, player, pos, incx, incy);
+ Threat right = this.countInRowOneDir(board, player, pos, -incx, -incy);
+
+ int count = left.count + right.count - 1;
+ int type = left.type + right.type;
+
+ return new Threat(count, type);
}
- private int walk(final IBoard2D board, final IPlayer player, final IPosition2D pos, int incx, int incy)
+ private Threat countInRowOneDir(final IBoard2D board, final IPlayer player, final IPosition2D pos, int incx, int incy)
{
int local = 0;
int count = 0;
+ int type = Threat.CLOSED;
+
int x = pos.row();
int y = pos.col();
@@ -100,6 +134,11 @@ private int walk(final IBoard2D board, final IPlayer player, final IPosition2D p
}
else
{
+ if (piece == null)
+ {
+ type = Threat.MINOR;
+ }
+
local = 0;
break;
}
@@ -107,8 +146,8 @@ private int walk(final IBoard2D board, final IPlayer player, final IPosition2D p
x += incx;
y += incy;
}
-
- return count;
+
+ return new Threat(count, type);
}
public void beforePlayerTurn(final IBoard2D board)
@@ -132,10 +171,10 @@ public boolean isTurnAvailable(final IBoard2D board, final ITurn turn)
}
}
}
-
+
return false;
}
-
+
public ArrayList getAvailableTurns(final IBoard2D board, final IPlayer player)
{
ArrayList result = new ArrayList();
@@ -187,16 +226,68 @@ public int evaluate(final IBoard2D board, int depth)
if (event == GameEvent.WIN)
{
- result = 10;
+ result = W_WIN;
}
else if (event == GameEvent.DRAW)
{
- result = 5;
+ result = W_DRAW;
}
-
- return result - distance;
+ else
+ {
+ ITurn last = board.getLastTurn();
+ result = this.evaluateThreats(board, last.getPiece().getPlayer());
+ }
+
+ return result - distance * W_FALLOFF;
}
+ private int evaluateThreats(final IBoard2D board, final IPlayer player)
+ {
+ int eval = 0;
+
+ for (int i = 0; i < board.getWidth(); i++)
+ {
+ for (int j = 0; j < board.getHeight(); j++)
+ {
+ ArrayList threats = this.walk(board, player, new Position2D(i, j));
+ Iterator iter = threats.iterator();
+ int threatsNumber = 0;
+ int increment = 0;
+ while (iter.hasNext())
+ {
+ Threat threat = (Threat) iter.next();
+ if (threat.count == 3 && threat.type != Threat.CLOSED)
+ {
+ increment += W_THREAT_THREE;
+ threatsNumber += 1;
+ if (threat.type == Threat.MAJOR)
+ {
+ increment *= B_MAJOR;
+ }
+ }
+ else if (threat.count == 2 && threat.type != Threat.CLOSED)
+ {
+ increment += W_THREAT_TWO;
+ threatsNumber += 1;
+ if (threat.type == Threat.MAJOR)
+ {
+ increment *= B_MAJOR;
+ }
+ }
+ }
+
+ if (threatsNumber > 2)
+ {
+ increment *= B_FORK;
+ }
+
+ eval += increment;
+ }
+ }
+
+ return eval;
+ }
+
public boolean isEndGame(final IBoard2D board)
{
return (this.checkGameEvent(board) != GameEvent.CONTINUE);
@@ -232,4 +323,20 @@ public void destroy()
}
private IGameEventListener gameEventListener;
+
+ private class Threat
+ {
+ public static final int CLOSED = 0;
+ public static final int MINOR = 1;
+ public static final int MAJOR = 2;
+
+ public Threat(int count, int type)
+ {
+ this.count = count;
+ this.type = type;
+ }
+
+ int count;
+ int type;
+ }
}
View
28 src/com/example/kindle/winningfour/gui/MenuPage.java
@@ -56,15 +56,15 @@ public void run()
public void onStop()
{
- KButton newButton = (KButton) MenuPage.this.getMenuItem(AppResources.KEY_MENU_NEW_GAME);
- KButton resumeButton = (KButton) MenuPage.this.getMenuItem(AppResources.KEY_MENU_RESUME_GAME);
+ KButton newOption = (KButton) MenuPage.this.getMenuItem(AppResources.KEY_MENU_NEW_GAME);
+ KButton resumeOption = (KButton) MenuPage.this.getMenuItem(AppResources.KEY_MENU_RESUME_GAME);
- if (MenuPage.this.focusOwner == resumeButton)
+ if (MenuPage.this.focusOwner == resumeOption)
{
- MenuPage.this.focusOwner = newButton;
+ MenuPage.this.focusOwner = newOption;
}
- resumeButton.setEnabled(false);
+ resumeOption.setEnabled(false);
}
};
@@ -80,11 +80,11 @@ public void initMenu()
{
if (!App.gamer.isSuspended())
{
- KButton newButton = (KButton) this.getMenuItem(AppResources.KEY_MENU_NEW_GAME);
- KButton resumeButton = (KButton) this.getMenuItem(AppResources.KEY_MENU_RESUME_GAME);
+ KButton newOption = (KButton) this.getMenuItem(AppResources.KEY_MENU_NEW_GAME);
+ KButton resumeOption = (KButton) this.getMenuItem(AppResources.KEY_MENU_RESUME_GAME);
- newButton.requestFocus();
- resumeButton.setEnabled(false);
+ newOption.requestFocus();
+ resumeOption.setEnabled(false);
}
}
@@ -94,7 +94,7 @@ public Container createMainMenu()
final KPanel panel = new KPanel(layout);
panel.setBackground(new Color(0x000000FF, true));
this.menuItems = new HashMap();
-
+
String[] menuItems = {AppResources.KEY_MENU_NEW_GAME,
AppResources.KEY_MENU_RESUME_GAME,
AppResources.KEY_MENU_OPTIONS,
@@ -126,10 +126,10 @@ public void run()
*/
protected Container addMenuItem(final String name, final Runnable action)
{
- KButton button = new KButton(name);
- button.setFont(AppResources.getFont(AppResources.ID_FONT_MENU));
+ KButton item = new KButton(name);
+ item.setFont(AppResources.getFont(AppResources.ID_FONT_MENU));
- button.addActionListener(new ActionListener()
+ item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
@@ -137,7 +137,7 @@ public void actionPerformed(ActionEvent e)
}
});
- return button;
+ return item;
}
protected Container getMenuItem(final String name)
View
4 src/com/example/kindle/winningfour/options/OptionsFactory.java
@@ -10,6 +10,7 @@
import com.example.kindle.winningfour.skins.ISkin;
import com.example.kindle.winningfour.skins.classic.ClassicSkin;
import com.example.kindle.winningfour.skins.sketchy.SketchySkin;
+import com.example.kindle.winningfour.skins.urban.UrbanSkin;
import com.example.kindle.winningfour.skins.wood.WoodSkin;
/**
@@ -61,6 +62,7 @@ else if (key.equals(AppOptions.OP_V_10X7))
String opponent = (String) App.opts.get(AppOptions.OP_T_OPPONENT);
IPlayer you = new HumanPlayer(Color.white, "Plato");
+
IPlayer opp = null;
if (opponent.equals(AppOptions.OP_V_COMPUTER))
@@ -125,7 +127,7 @@ else if (key.equals(AppOptions.OP_V_CHEESE))
}
else if (key.equals(AppOptions.OP_V_URBAN))
{
- result = (ISkin) new ClassicSkin(bs);
+ result = (ISkin) new UrbanSkin(bs);
}
return result;
View
33 src/com/example/kindle/winningfour/skins/BaseSkin.java
@@ -14,6 +14,9 @@
public class BaseSkin implements ISkin
{
+ public static final double DESIGN_WIDTH = 600.0;
+ public static final double DESIGN_HEIGHT = 760.0;
+
public BaseSkin(Dimension boardSize)
{
this.boardSize = boardSize;
@@ -23,10 +26,34 @@ public BoardLayout getLayout(final Dimension size)
{
return null;
}
+
+ protected BoardLayout createLayout(final Dimension size, final Rectangle rect, int sely, int gapx)
+ {
+ BoardLayout result = new BoardLayout();
+
+ double wfactor = size.width / BaseSkin.DESIGN_WIDTH;
+ double hfactor = size.height / BaseSkin.DESIGN_HEIGHT;
+
+ result.boardRect.x = (int) (rect.x * wfactor);
+ result.boardRect.y = (int) (rect.y * hfactor);
+ result.boardRect.width = (int) (rect.width * wfactor);
+ result.boardRect.height = (int) (rect.height * hfactor);
+
+ result.selectorY = (int) (sely * hfactor);
+
+ int cols = this.boardSize.width;
+ int rows = this.boardSize.height;
+ result.pieceSizeX = (int) ((result.boardRect.width - gapx*(cols - 1)) / cols);
+ result.pieceSizeY = result.pieceSizeX;
+
+ result.pieceGapX = gapx;
+ result.pieceGapY = (result.boardRect.height - (result.pieceSizeY * rows))/(rows - 1);
+
+ return result;
+ }
public void paintBoard(final Graphics g, final Component parent)
{
- this.paintHoles(g, parent);
}
public void paintBoardItem(final Graphics g, final Component parent, final BoardItem item)
@@ -69,8 +96,8 @@ protected void paintImage(final Graphics g, final Component parent, String id, f
protected void paintImageToGrid(final Graphics g, final Component parent, String id,
final BoardLayout l, int row, int col)
{
- int x = (int) (l.boardLeftTopX + row*(l.pieceSizeX+l.pieceGapX));
- int y = (int) (l.boardLeftTopY + col*(l.pieceSizeY+l.pieceGapY));
+ int x = (int) (l.boardRect.x + row*(l.pieceSizeX+l.pieceGapX));
+ int y = (int) (l.boardRect.y + col*(l.pieceSizeY+l.pieceGapY));
this.paintImage(g, parent, id, new Rectangle(x, y, l.pieceSizeX, l.pieceSizeY));
}
View
5 src/com/example/kindle/winningfour/skins/BoardLayout.java
@@ -1,9 +1,10 @@
package com.example.kindle.winningfour.skins;
+import java.awt.Rectangle;
+
public class BoardLayout
{
- public int boardLeftTopX;
- public int boardLeftTopY;
+ public Rectangle boardRect = new Rectangle();
public int selectorY;
public int pieceSizeX;
public int pieceSizeY;
View
28 src/com/example/kindle/winningfour/skins/classic/ClassicSkin.java
@@ -3,6 +3,7 @@
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
+import java.awt.Rectangle;
import com.example.kindle.winningfour.boardgame.BoardItem;
import com.example.kindle.winningfour.skins.BaseSkin;
@@ -13,29 +14,17 @@
public ClassicSkin(final Dimension boardSize)
{
super(boardSize);
+ this.boardRect = new Rectangle(100, 226, 400, 345);
}
public BoardLayout getLayout(final Dimension size)
{
- BoardLayout result = new BoardLayout();
-
- result.boardLeftTopX = (int) (this.boardLeftTopX * size.width);
- result.boardLeftTopY = (int) (this.boardLeftTopY * size.height);
- result.selectorY = (int) (this.selectorY * size.height);
-
- int cols = this.boardSize.width;
- result.pieceSizeX = (int) ((size.width - 2*result.boardLeftTopX - this.pieceGap*(cols-1)) / cols);
- result.pieceSizeY = result.pieceSizeX;
-
- result.pieceGapX = this.pieceGap;
- result.pieceGapY = this.pieceGap;
-
- return result;
+ return this.createLayout(size, this.boardRect, this.selectorY, this.pieceGapX);
}
public void paintBoard(final Graphics g, final Component parent)
{
- super.paintBoard(g, parent);
+ this.paintHoles(g, parent);
}
public void paintBoardItem(final Graphics g, final Component parent, final BoardItem item)
@@ -48,11 +37,10 @@ public String getName()
return "classic";
}
- // percents calculated from 600 x 780 factor
- private double selectorY = 580.0/760.0;
- private double boardLeftTopX = 100.0/600.0;
- private double boardLeftTopY = 220.0/760.0;
+ // fraction calculated from 600 x 780 factor
+ private int selectorY = 580;
+ private Rectangle boardRect;
// pixels
- private int pieceGap = 4;
+ private int pieceGapX = 4;
}
View
27 src/com/example/kindle/winningfour/skins/sketchy/SketchySkin.java
@@ -3,6 +3,7 @@
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
+import java.awt.Rectangle;
import com.example.kindle.winningfour.boardgame.BoardItem;
import com.example.kindle.winningfour.skins.BaseSkin;
@@ -13,29 +14,17 @@
public SketchySkin(final Dimension boardSize)
{
super(boardSize);
+ this.boardRect = new Rectangle(28, 117, 546, 418);
}
public BoardLayout getLayout(final Dimension size)
{
- BoardLayout result = new BoardLayout();
-
- result.boardLeftTopX = (int) (this.boardLeftTopX * size.width);
- result.boardLeftTopY = (int) (this.boardLeftTopY * size.height);
- result.selectorY = (int) (this.selectorY * size.height);
-
- int cols = this.boardSize.width;
- result.pieceSizeX = (int) ((size.width - 2*result.boardLeftTopX - this.pieceGapX*(cols-1)) / cols);
- result.pieceSizeY = result.pieceSizeX;
-
- result.pieceGapX = this.pieceGapX;
- result.pieceGapY = this.pieceGapY;
-
- return result;
+ return this.createLayout(size, this.boardRect, this.selectorY, this.pieceGapX);
}
public void paintBoard(final Graphics g, final Component parent)
{
- super.paintBoard(g, parent);
+ this.paintHoles(g, parent);
}
public void paintBoardItem(final Graphics g, final Component parent, final BoardItem item)
@@ -48,10 +37,8 @@ public String getName()
return "sketchy";
}
- private double selectorY = 580.0/760.0;
- private double boardLeftTopX = 90.0/600.0;
- private double boardLeftTopY = 130.0/760.0;
+ private int selectorY = 580;
+ private Rectangle boardRect;
- private int pieceGapX = 8;
- private int pieceGapY = 4;
+ private int pieceGapX = 4;
}
View
44 src/com/example/kindle/winningfour/skins/urban/UrbanSkin.java
@@ -0,0 +1,44 @@
+package com.example.kindle.winningfour.skins.urban;
+
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+
+import com.example.kindle.winningfour.boardgame.BoardItem;
+import com.example.kindle.winningfour.skins.BaseSkin;
+import com.example.kindle.winningfour.skins.BoardLayout;
+
+public class UrbanSkin extends BaseSkin
+{
+ public UrbanSkin(final Dimension boardSize)
+ {
+ super(boardSize);
+ this.boardRect = new Rectangle(28, 117, 546, 518);
+ }
+
+ public BoardLayout getLayout(final Dimension size)
+ {
+ return this.createLayout(size, this.boardRect, this.selectorY, this.pieceGapX);
+ }
+
+ public void paintBoard(final Graphics g, final Component parent)
+ {
+ super.paintBoard(g, parent);
+ }
+
+ public void paintBoardItem(final Graphics g, final Component parent, final BoardItem item)
+ {
+ super.paintBoardItem(g, parent, item);
+ }
+
+ public String getName()
+ {
+ return "urban";
+ }
+
+ private int selectorY = 660;
+ private Rectangle boardRect;
+
+ private int pieceGapX = 4;
+}
View
BIN src/com/example/kindle/winningfour/skins/urban/background.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN src/com/example/kindle/winningfour/skins/urban/black.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN src/com/example/kindle/winningfour/skins/urban/black_selected.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN src/com/example/kindle/winningfour/skins/urban/board.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN src/com/example/kindle/winningfour/skins/urban/selector.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN src/com/example/kindle/winningfour/skins/urban/urban_skin_draft.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN src/com/example/kindle/winningfour/skins/urban/white.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN src/com/example/kindle/winningfour/skins/urban/white_selected.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
37 src/com/example/kindle/winningfour/skins/wood/WoodSkin.java
@@ -14,38 +14,28 @@
public WoodSkin(final Dimension boardSize)
{
super(boardSize);
+ this.boardRect = new Rectangle(100, 210, 400, 300);
}
public BoardLayout getLayout(final Dimension size)
{
- BoardLayout result = new BoardLayout();
-
- result.boardLeftTopX = (int) (this.boardLeftTopX * size.width);
- result.boardLeftTopY = (int) (this.boardLeftTopY * size.height);
- result.selectorY = (int) (this.selectorY * size.height);
-
- int rows = this.boardSize.width;
- result.pieceSizeX = (int) ((size.width - 2*result.boardLeftTopX - this.pieceGapX*(rows-1)) / rows);
- result.pieceSizeY = result.pieceSizeX;
-
- result.pieceGapX = this.pieceGapX;
- result.pieceGapY = this.pieceGapY;
-
- return result;
+ return this.createLayout(size, this.boardRect, this.selectorY, this.pieceGapX);
}
public void paintBoard(final Graphics g, final Component parent)
{
Dimension size = parent.getSize();
BoardLayout l = this.getLayout(size);
+
+ double hfactor = size.height / BaseSkin.DESIGN_HEIGHT;
for (int i = 0; i < this.boardSize.width + 1; i++)
{
int sx = l.pieceSizeX;
int gap = l.pieceGapX;
- int x = (int) (l.boardLeftTopX + i*(sx+gap));
- int ry = (this.boardSize.height) * l.pieceSizeY;
- int y = (int) (this.boardPlaneY * size.height) - ry;
+ int x = (int) (l.boardRect.x + i*(sx+gap));
+ int ry = (int) (this.boardRect.height * hfactor);
+ int y = (int) (this.boardRect.y * hfactor);
int rx = 2*sx/3;
this.paintImage(g, parent, "stick.png", new Rectangle(x-gap-rx+rx/2, y, rx, ry));
@@ -60,9 +50,11 @@ public void paintBoardItem(final Graphics g, final Component parent, final Board
int overlap = l.pieceSizeY/8;
int oy = (overlap - 1) * this.boardSize.height;
- int y = (int) (this.boardPlaneY * size.height) - (this.boardSize.height) * l.pieceSizeY;
+ double hfactor = size.height / BaseSkin.DESIGN_HEIGHT;
+
+ int y = (int) (this.boardRect.height * hfactor - this.boardSize.height * l.pieceSizeY);
y += item.getPosition().col()*(l.pieceSizeY + l.pieceGapY - overlap) + oy;
- int x = l.boardLeftTopX + item.getPosition().row()*(l.pieceSizeX + l.pieceGapX);
+ int x = l.boardRect.x + item.getPosition().row()*(l.pieceSizeX + l.pieceGapX);
this.paintPiece(g, parent, item.getPiece(), new Rectangle(x, y, l.pieceSizeX, l.pieceSizeY));
}
@@ -72,11 +64,8 @@ public String getName()
return "wood";
}
- private double selectorY = 600.0/760.0;
- private double boardLeftTopX = 100.0/600.0;
- private double boardLeftTopY = 220.0/760.0;
- private double boardPlaneY = 500.0/760.0;
+ private int selectorY = 600;
+ private Rectangle boardRect;
private int pieceGapX = 4;
- private int pieceGapY = 2;
}

No commit comments for this range

Something went wrong with that request. Please try again.