Partial crosses fix + fix validMoves for Random Player + partial fix an issue when clicking on right bottom corner of (1,1) box, game think is (2, 2)
This commit is contained in:
parent
122200a391
commit
424d969598
@ -28,11 +28,11 @@ public class WindowMouseListener implements MouseListener {
|
|||||||
y -= initialHeight * 2;
|
y -= initialHeight * 2;
|
||||||
if(x >= initialWidth && x <= initialWidth * 11) {
|
if(x >= initialWidth && x <= initialWidth * 11) {
|
||||||
x -= initialWidth;
|
x -= initialWidth;
|
||||||
lastInput = new Pair<>(y / initialHeight, x / initialWidth);
|
lastInput = new Pair<>((y + 2) / initialHeight, (x + 2) / initialWidth);
|
||||||
playerIdLastInput = 1;
|
playerIdLastInput = 1;
|
||||||
} else if(x >= initialHeight * 13 && x <= window.width) {
|
} else if(x >= initialHeight * 13 && x <= window.width) {
|
||||||
x -= initialWidth * 13;
|
x -= initialWidth * 13;
|
||||||
lastInput = new Pair<>(y / initialHeight, x / initialWidth);
|
lastInput = new Pair<>((y + 2) / initialHeight, (x + 2) / initialWidth);
|
||||||
playerIdLastInput = 2;
|
playerIdLastInput = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ public abstract class AbstractPlayer implements Player {
|
|||||||
for(int x = 0; x < 10; x++){
|
for(int x = 0; x < 10; x++){
|
||||||
for(int y = 0; y < 10; y++) {
|
for(int y = 0; y < 10; y++) {
|
||||||
Pair<Integer, Integer> coords = new Pair<>(x,y);
|
Pair<Integer, Integer> coords = new Pair<>(x,y);
|
||||||
if(!moves.contains(new Triplet<>(coords, true)) || !moves.contains(new Triplet<>(coords, false))){
|
if(!(moves.contains(new Triplet<>(coords, true)) || moves.contains(new Triplet<>(coords, false)))){
|
||||||
validMovesList.add(new Pair<>(x,y));
|
validMovesList.add(new Pair<>(x,y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -213,30 +213,33 @@ public class Window extends AbstractView {
|
|||||||
g.setColor(new Color(0, 0, 255));
|
g.setColor(new Color(0, 0, 255));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
g2d.fillRect(x1, y1, shipWidth, shipHeight);
|
g2d.fillRoundRect(x1 + 1, y1 + 1, shipWidth - 1, shipHeight - 1, 25, 25);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(int i = 1; i < 3; ++i) {
|
for(int i = 1; i < 3; ++i) {
|
||||||
Player player = game.players[i-1];
|
Player player = game.players[i-1];
|
||||||
int halfBoxSizeWidth = initialWidth / 2;
|
int halfBoxSizeWidth = initialWidth / 2;
|
||||||
int halfBoxSizeHeight = initialHeight / 2;
|
int halfBoxSizeHeight = initialHeight / 2;
|
||||||
int sqrt = (int) Math.sqrt(initialHeight * initialHeight + initialWidth * initialWidth);
|
float rectangleSize = initialWidth / 4f;
|
||||||
|
int sqrt = (int) Math.sqrt(initialHeight * initialHeight + initialWidth * initialWidth) - 10;
|
||||||
for(Triplet<Integer, Integer, Boolean> move : player.getMoves()) {
|
for(Triplet<Integer, Integer, Boolean> move : player.getMoves()) {
|
||||||
int x1 = (i == 1 ? initialWidth * 13 : initialWidth) + initialWidth * move.getMiddle();
|
int x1 = (i == 1 ? initialWidth * 13 : initialWidth) + initialWidth * move.getMiddle();
|
||||||
int y1 = initialHeight * 2 + initialHeight * move.getLeft();
|
int y1 = initialHeight * 2 + initialHeight * move.getLeft() + 8;
|
||||||
RoundRectangle2D rect = new RoundRectangle2D.Float(x1, y1, initialWidth / 4f, sqrt, 15, 15);
|
RoundRectangle2D cross1 = new RoundRectangle2D.Float(x1, y1, rectangleSize, sqrt, 15, 15);
|
||||||
|
RoundRectangle2D cross2 = new RoundRectangle2D.Float(x1 + initialWidth - 9, y1 - 9, rectangleSize, sqrt, 15, 15);
|
||||||
if(move.getRight()) {
|
if(move.getRight()) {
|
||||||
g.setColor(new Color(255, 0, 0));
|
g.setColor(new Color(255, 0, 0));
|
||||||
} else {
|
} else {
|
||||||
g.setColor(new Color(0, 123, 255));
|
g.setColor(new Color(0, 123, 255));
|
||||||
}
|
}
|
||||||
g2d.rotate(Math.toRadians(45), x1, y1);
|
|
||||||
g2d.fill(rect);
|
|
||||||
// g2d.rotate(Math.toRadians(-45), x1, y1);
|
|
||||||
g2d.rotate(Math.toRadians(-90), x1 + halfBoxSizeWidth, y1 + halfBoxSizeHeight);
|
|
||||||
g2d.fill(rect);
|
|
||||||
g2d.rotate(Math.toRadians(90), x1 + halfBoxSizeWidth, y1 + halfBoxSizeHeight);
|
|
||||||
g2d.rotate(Math.toRadians(-45), x1, y1);
|
g2d.rotate(Math.toRadians(-45), x1, y1);
|
||||||
|
g2d.fill(cross1);
|
||||||
|
g2d.rotate(Math.toRadians(45), x1, y1);
|
||||||
|
g2d.rotate(Math.toRadians(45), x1 + initialWidth - 9, y1 - 9);
|
||||||
|
g2d.fill(cross2);
|
||||||
|
g2d.rotate(Math.toRadians(-45), x1 + initialWidth - 9, y1 - 9);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println(window);
|
System.out.println(window);
|
||||||
|
Loading…
Reference in New Issue
Block a user