Browse Source

Bugfix draw order

feature_TicTacToe_Playfield
kfkama 3 years ago
parent
commit
848a5ba499
  1. 6
      src/main/java/TicTacToe/Cell.java
  2. 22
      src/main/java/TicTacToe/TicTacToeGame.java

6
src/main/java/TicTacToe/Cell.java

@ -41,12 +41,12 @@ public class Cell extends JButton {
g2.setPaint(Color.white); g2.setPaint(Color.white);
switch (playerID) { switch (playerID) {
case 1: case 1:
g2.drawOval(5, 5, 90, 90);
break;
case 2:
g2.drawLine(5, 5, 90, 90); g2.drawLine(5, 5, 90, 90);
g2.drawLine(90, 5, 5, 90); g2.drawLine(90, 5, 5, 90);
break; break;
case 2:
g2.drawOval(5, 5, 90, 90);
break;
} }
} }

22
src/main/java/TicTacToe/TicTacToeGame.java

@ -88,19 +88,21 @@ public class TicTacToeGame extends JPanel {
JOptionPane.showMessageDialog(getParent(),"Player: " + playerID + " Wins!"); JOptionPane.showMessageDialog(getParent(),"Player: " + playerID + " Wins!");
scoreboard.addPoint(playerID); scoreboard.addPoint(playerID);
resetGame(); resetGame();
} else {
turns++;
if(turns >= playFieldSize) {
JOptionPane.showMessageDialog(getParent(),"Draw!");
scoreboard.addPoint(0);
resetGame();
}
playerID++;
if(playerID >= maxPlayers) {
playerID = 1;
}
} }
turns++;
if(turns > playFieldSize) {
JOptionPane.showMessageDialog(getParent(),"Draw!");
scoreboard.addPoint(0);
resetGame();
}
playerID++;
if(playerID >= maxPlayers) {
playerID = 1;
}
} }
public int checkPlayfield() { public int checkPlayfield() {

Loading…
Cancel
Save