20.09 pa
This commit is contained in:
BIN
Game.class
BIN
Game.class
Binary file not shown.
133
Game.java
133
Game.java
@@ -2,6 +2,9 @@ import javafx.scene.shape.Shape;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.shape.Circle;
|
||||||
|
import java.util.AbstractList;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Beschreibung
|
* Beschreibung
|
||||||
@@ -22,31 +25,50 @@ public class Game {
|
|||||||
public Pane game_board;
|
public Pane game_board;
|
||||||
public Chip current_selection;
|
public Chip current_selection;
|
||||||
|
|
||||||
public void start(Pane gameBoard) {
|
public Label LTop;
|
||||||
|
|
||||||
|
public Circle[] white_player_chips = new Circle[9];
|
||||||
|
public Circle[] black_player_chips = new Circle[9];
|
||||||
|
|
||||||
|
|
||||||
|
public void start(Pane gameBoard, Label label) {
|
||||||
game_board = gameBoard;
|
game_board = gameBoard;
|
||||||
|
LTop = label;
|
||||||
|
|
||||||
|
setLabelText("White Turn");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void chip_button_clicked(MuehleButton button) {
|
public void chip_button_clicked(MuehleButton button) {
|
||||||
if (game_state == 0) {
|
if (game_state == 0) {
|
||||||
|
Chip newChip;
|
||||||
if (currentTurnPlayer == "White") {
|
if (currentTurnPlayer == "White") {
|
||||||
addChip(button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.WHITE);
|
newChip = addChip(button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.WHITE);
|
||||||
white_chips--;
|
white_chips--;
|
||||||
|
setChipCount(white_chips,"White");
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
addChip(button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.BLACK);
|
newChip = addChip(button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.BLACK);
|
||||||
black_chips--;
|
black_chips--;
|
||||||
|
setChipCount(white_chips,"Black");
|
||||||
}
|
}
|
||||||
|
if (checkCombo(newChip)) {
|
||||||
|
System.out.println("Comb!");
|
||||||
|
} // end of if(newChip);
|
||||||
game_board.getChildren().remove(button.getShape());
|
game_board.getChildren().remove(button.getShape());
|
||||||
nextTurn();
|
nextTurn();
|
||||||
} // end of if
|
}
|
||||||
|
if(game_state == 1) {
|
||||||
|
// second state of game
|
||||||
|
setLabelText("Second State");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public void addChip(int relX, int relY,double absX, double absY, Color color) {
|
public Chip addChip(int relX, int relY,double absX, double absY, Color color) {
|
||||||
Chip chip = new Chip(relX,relY,absX,absY,color,this);
|
Chip chip = new Chip(relX,relY,absX,absY,color,this);
|
||||||
|
chips.add(chip);
|
||||||
addShape(chip.getShape());
|
addShape(chip.getShape());
|
||||||
|
return chip;
|
||||||
}
|
}
|
||||||
public void addShape(Shape newShape) {
|
public void addShape(Shape newShape) {
|
||||||
game_board.getChildren().add(newShape);
|
game_board.getChildren().add(newShape);
|
||||||
@@ -57,11 +79,108 @@ public class Game {
|
|||||||
|
|
||||||
}
|
}
|
||||||
public void nextTurn() {
|
public void nextTurn() {
|
||||||
|
if (white_chips == 0 && black_chips == 0) {
|
||||||
|
game_state = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (currentTurnPlayer == "White") {
|
if (currentTurnPlayer == "White") {
|
||||||
|
setLabelText("Black Turn");
|
||||||
currentTurnPlayer = "Black";
|
currentTurnPlayer = "Black";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
currentTurnPlayer = "White";
|
currentTurnPlayer = "White";
|
||||||
|
setLabelText("White Turn");
|
||||||
|
} // end of if-else
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setLabelText(String value) {
|
||||||
|
LTop.setText(value);
|
||||||
|
}
|
||||||
|
public boolean checkCombo(Chip chip) {
|
||||||
|
return checkCombo(chip.relativeX, chip.relativeY);
|
||||||
|
}
|
||||||
|
public boolean checkCombo(int relX, int relY) {
|
||||||
|
ArrayList<Chip> hChips = getHorizontalCloseChips(relX,relY);
|
||||||
|
ArrayList<Chip> vChips = getHorizontalCloseChips(relX,relY);
|
||||||
|
System.out.println(hChips.get(0).relativeX);
|
||||||
|
Chip start_chip = getChipByPos(relX,relY);
|
||||||
|
|
||||||
|
if (start_chip.color == hChips.get(0).color && start_chip.color == hChips.get(1).color) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (start_chip.color == vChips.get(0).color && start_chip.color == vChips.get(1).color) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Chip> getHorizontalCloseChips(int relX, int relY) {
|
||||||
|
ArrayList<Chip> result = new ArrayList<Chip>();
|
||||||
|
if (relX == 0) {
|
||||||
|
result.add(getChipByPos(1,relY));
|
||||||
|
result.add(getChipByPos(2,relY));
|
||||||
|
}
|
||||||
|
else if ( relX == 1) {
|
||||||
|
result.add(getChipByPos(0,relY));
|
||||||
|
result.add(getChipByPos(2,relY));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result.add(getChipByPos(0,relY));
|
||||||
|
result.add(getChipByPos(1,relY));
|
||||||
|
} // end of if-else
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public ArrayList<Chip> getVerticalCloseChips(int relX, int relY) {
|
||||||
|
ArrayList<Chip> result = new ArrayList<Chip>();
|
||||||
|
if (relY == 0) {
|
||||||
|
result.add(getChipByPos(relX,1));
|
||||||
|
result.add(getChipByPos(relX,2));
|
||||||
|
}
|
||||||
|
else if ( relY == 1) {
|
||||||
|
result.add(getChipByPos(relX,0));
|
||||||
|
result.add(getChipByPos(relX,2));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result.add(getChipByPos(relX,0));
|
||||||
|
result.add(getChipByPos(relX,1));
|
||||||
|
} // end of if-else
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public Chip getChipByPos(int relX, int relY) {
|
||||||
|
|
||||||
|
for (int i = 0; i < chips.size()-1; i++) {
|
||||||
|
if (chips.get(i).relativeX == relX && chips.get(i).relativeY == relY ) {
|
||||||
|
return chips.get(i);
|
||||||
|
} // end of if
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public void setChipCount(int value, String player) {
|
||||||
|
System.out.println(white_chips-1);
|
||||||
|
if (player == "White") {
|
||||||
|
if (white_chips == 0) {
|
||||||
|
for (int i = 0; i < white_player_chips.length -1; i++) {
|
||||||
|
white_player_chips[i].setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = white_player_chips.length-1; i >= value; i--) {
|
||||||
|
white_player_chips[i].setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
{
|
||||||
|
if (white_chips == 0) {
|
||||||
|
for (int i = 0; i < black_player_chips.length -1; i++) {
|
||||||
|
black_player_chips[i].setVisible(false);
|
||||||
|
} // end of for
|
||||||
|
} // end of if
|
||||||
|
for (int i = black_player_chips.length-1; i >= value; i--) {
|
||||||
|
black_player_chips[i].setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
} // end of if-else
|
} // end of if-else
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
137
Game.~ava
137
Game.~ava
@@ -2,6 +2,9 @@ import javafx.scene.shape.Shape;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.shape.Circle;
|
||||||
|
import java.util.AbstractList;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Beschreibung
|
* Beschreibung
|
||||||
@@ -13,7 +16,7 @@ import javafx.scene.paint.Color;
|
|||||||
public class Game {
|
public class Game {
|
||||||
|
|
||||||
public String currentTurnPlayer = "White";
|
public String currentTurnPlayer = "White";
|
||||||
public int game_state = 0; // 0 == players placing their chips; 1 = players moving their chips
|
public int game_state = 0; // 0 == players placing their chips; 1 = players moving their chips; 2 = player can remove chip
|
||||||
public int white_chips = 9;
|
public int white_chips = 9;
|
||||||
public int black_chips = 9;
|
public int black_chips = 9;
|
||||||
|
|
||||||
@@ -22,31 +25,50 @@ public class Game {
|
|||||||
public Pane game_board;
|
public Pane game_board;
|
||||||
public Chip current_selection;
|
public Chip current_selection;
|
||||||
|
|
||||||
public void start(Pane gameBoard) {
|
public Label LTop;
|
||||||
|
|
||||||
|
public Circle[] white_player_chips = new Circle[9];
|
||||||
|
public Circle[] black_player_chips = new Circle[9];
|
||||||
|
|
||||||
|
|
||||||
|
public void start(Pane gameBoard, Label label) {
|
||||||
game_board = gameBoard;
|
game_board = gameBoard;
|
||||||
|
LTop = label;
|
||||||
|
|
||||||
|
setLabelText("White Turn");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void chip_button_clicked(MuehleButton button) {
|
public void chip_button_clicked(MuehleButton button) {
|
||||||
if (game_state == 0) {
|
if (game_state == 0) {
|
||||||
|
Chip newChip;
|
||||||
if (currentTurnPlayer == "White") {
|
if (currentTurnPlayer == "White") {
|
||||||
addChip(button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.WHITE);
|
newChip = addChip(button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.WHITE);
|
||||||
white_chips--;
|
white_chips--;
|
||||||
|
setChipCount(white_chips,"White");
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
addChip(button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.BLACK);
|
newChip = addChip(button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.BLACK);
|
||||||
black_chips--;
|
black_chips--;
|
||||||
|
setChipCount(white_chips,"Black");
|
||||||
}
|
}
|
||||||
|
if (checkCombo(newChip)) {
|
||||||
|
System.out.println("Comb!");
|
||||||
|
} // end of if(newChip);
|
||||||
game_board.getChildren().remove(button.getShape());
|
game_board.getChildren().remove(button.getShape());
|
||||||
nextTurn();
|
nextTurn();
|
||||||
} // end of if
|
}
|
||||||
|
if(game_state == 1) {
|
||||||
|
// second state of game
|
||||||
|
setLabelText("Second State");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public void addChip(int relX, int relY,double absX, double absY, Color color) {
|
public Chip addChip(int relX, int relY,double absX, double absY, Color color) {
|
||||||
Chip chip = new Chip(relX,relY,absX,absY,color,this);
|
Chip chip = new Chip(relX,relY,absX,absY,color,this);
|
||||||
|
chips.add(chip);
|
||||||
addShape(chip.getShape());
|
addShape(chip.getShape());
|
||||||
|
return chip;
|
||||||
}
|
}
|
||||||
public void addShape(Shape newShape) {
|
public void addShape(Shape newShape) {
|
||||||
game_board.getChildren().add(newShape);
|
game_board.getChildren().add(newShape);
|
||||||
@@ -57,11 +79,110 @@ public class Game {
|
|||||||
|
|
||||||
}
|
}
|
||||||
public void nextTurn() {
|
public void nextTurn() {
|
||||||
|
if (white_chips == 0 && black_chips == 0) {
|
||||||
|
game_state = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (currentTurnPlayer == "White") {
|
if (currentTurnPlayer == "White") {
|
||||||
|
setLabelText("Black Turn");
|
||||||
currentTurnPlayer = "Black";
|
currentTurnPlayer = "Black";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
currentTurnPlayer = "White";
|
currentTurnPlayer = "White";
|
||||||
|
setLabelText("White Turn");
|
||||||
|
} // end of if-else
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setLabelText(String value) {
|
||||||
|
LTop.setText(value);
|
||||||
|
}
|
||||||
|
public boolean checkCombo(Chip chip) {
|
||||||
|
return checkCombo(chip.relativeX, chip.relativeY);
|
||||||
|
}
|
||||||
|
public boolean checkCombo(int relX, int relY) {
|
||||||
|
ArrayList<Chip> hChips = getHorizontalCloseChips(relX,relY);
|
||||||
|
ArrayList<Chip> vChips = getHorizontalCloseChips(relX,relY);
|
||||||
|
System.out.println(hChips.get(0).relativeX);
|
||||||
|
Chip start_chip = getChipByPos(relX,relY);
|
||||||
|
|
||||||
|
if (start_chip.color == hChips.get(0).color && start_chip.color == hChips.get(1).color) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (start_chip.color == vChips.get(0).color && start_chip.color == vChips.get(1).color) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Chip> getHorizontalCloseChips(int relX, int relY) {
|
||||||
|
ArrayList<Chip> result = new ArrayList<Chip>();
|
||||||
|
if (relX == 0) {
|
||||||
|
result.add(getChipByPos(1,relY));
|
||||||
|
result.add(getChipByPos(2,relY));
|
||||||
|
}
|
||||||
|
else if ( relX == 1) {
|
||||||
|
result.add(getChipByPos(0,relY));
|
||||||
|
result.add(getChipByPos(2,relY));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result.add(getChipByPos(0,relY));
|
||||||
|
result.add(getChipByPos(1,relY));
|
||||||
|
} // end of if-else
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public ArrayList<Chip> getVerticalCloseChips(int relX, int relY) {
|
||||||
|
ArrayList<Chip> result = new ArrayList<Chip>();
|
||||||
|
if (relY == 0) {
|
||||||
|
result.add(getChipByPos(relX,1));
|
||||||
|
result.add(getChipByPos(relX,2));
|
||||||
|
}
|
||||||
|
else if ( relY == 1) {
|
||||||
|
result.add(getChipByPos(relX,0));
|
||||||
|
result.add(getChipByPos(relX,2));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result.add(getChipByPos(relX,0));
|
||||||
|
result.add(getChipByPos(relX,1));
|
||||||
|
} // end of if-else
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public Chip getChipByPos(int relX, int relY) {
|
||||||
|
|
||||||
|
for (int i = 0; i < chips.size()-1; i++) {
|
||||||
|
System.out.println(i);
|
||||||
|
if (chips.get(i).relativeX == relX && chips.get(i).relativeY == relY ) {
|
||||||
|
System.out.println("Found");
|
||||||
|
return chips.get(i);
|
||||||
|
} // end of if
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public void setChipCount(int value, String player) {
|
||||||
|
System.out.println(white_chips-1);
|
||||||
|
if (player == "White") {
|
||||||
|
if (white_chips == 0) {
|
||||||
|
for (int i = 0; i < white_player_chips.length -1; i++) {
|
||||||
|
white_player_chips[i].setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = white_player_chips.length-1; i >= value; i--) {
|
||||||
|
white_player_chips[i].setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
{
|
||||||
|
if (white_chips == 0) {
|
||||||
|
for (int i = 0; i < black_player_chips.length -1; i++) {
|
||||||
|
black_player_chips[i].setVisible(false);
|
||||||
|
} // end of for
|
||||||
|
} // end of if
|
||||||
|
for (int i = black_player_chips.length-1; i >= value; i--) {
|
||||||
|
black_player_chips[i].setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
} // end of if-else
|
} // end of if-else
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BIN
Muehle.class
BIN
Muehle.class
Binary file not shown.
80
Muehle.java
80
Muehle.java
@@ -12,6 +12,7 @@ import javafx.scene.shape.Line;
|
|||||||
import javafx.event.Event;
|
import javafx.event.Event;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
import javafx.scene.input.MouseEvent;
|
import javafx.scene.input.MouseEvent;
|
||||||
|
import javafx.scene.shape.Circle;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Beschreibung
|
* Beschreibung
|
||||||
@@ -38,7 +39,9 @@ public class Muehle extends Application {
|
|||||||
Scene scene = new Scene(root, 1080, 820);
|
Scene scene = new Scene(root, 1080, 820);
|
||||||
|
|
||||||
|
|
||||||
game.start(game_board);
|
game.start(game_board,lTop);
|
||||||
|
|
||||||
|
drawPlayerChips();
|
||||||
|
|
||||||
//lTop.setAlignment();
|
//lTop.setAlignment();
|
||||||
setTopLabel("Test Label");
|
setTopLabel("Test Label");
|
||||||
@@ -131,42 +134,42 @@ public class Muehle extends Application {
|
|||||||
Color button_color = Color.BLUE;
|
Color button_color = Color.BLUE;
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
MuehleButton button = new MuehleButton(0,i,topLeftX,topLeftY+ i*325,button_color,game);
|
MuehleButton button = new MuehleButton(0,i,topLeftX,topLeftY+ i*325,button_color,game);
|
||||||
shapes.add(button.getShape());
|
shapes.add(button.getShape());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
MuehleButton button = new MuehleButton(1,i,topRightX -230,topLeftY+ i*100,button_color,game);
|
MuehleButton button = new MuehleButton(1,i,topRightX -230,topLeftY+ i*100,button_color,game);
|
||||||
shapes.add(button.getShape());
|
shapes.add(button.getShape());
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
|
||||||
MuehleButton button = new MuehleButton(2,i,topRightX + 140,topLeftY+ i*325,button_color,game);
|
|
||||||
shapes.add(button.getShape());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
|
||||||
MuehleButton button = new MuehleButton(0,i,topLeftX + 100,topLeftY+ i*220 +100,button_color,game);
|
|
||||||
shapes.add(button.getShape());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
MuehleButton button = new MuehleButton(2,i,topRightX +40,topLeftY+ i*220 +100,button_color,game);
|
MuehleButton button = new MuehleButton(2,i,topRightX + 140,topLeftY+ i*325,button_color,game);
|
||||||
shapes.add(button.getShape());
|
shapes.add(button.getShape());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
MuehleButton button = new MuehleButton(1,i,topRightX -230,topLeftY+ i*100 +460,button_color,game);
|
MuehleButton button = new MuehleButton(0,i,topLeftX + 100,topLeftY+ i*220 +100,button_color,game);
|
||||||
shapes.add(button.getShape());
|
shapes.add(button.getShape());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
MuehleButton button = new MuehleButton(0,i,topLeftX +200,topLeftY+ i*130 +200,button_color,game);
|
MuehleButton button = new MuehleButton(2,i,topRightX +40,topLeftY+ i*220 +100,button_color,game);
|
||||||
shapes.add(button.getShape());
|
shapes.add(button.getShape());
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
MuehleButton button = new MuehleButton(2,i,topLeftX +540,topLeftY+ i*130 +200,button_color,game);
|
MuehleButton button = new MuehleButton(1,i,topRightX -230,topLeftY+ i*100 +460,button_color,game);
|
||||||
shapes.add(button.getShape());
|
shapes.add(button.getShape());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
MuehleButton button = new MuehleButton(0,i,topLeftX +200,topLeftY+ i*130 +200,button_color,game);
|
||||||
|
shapes.add(button.getShape());
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
MuehleButton button = new MuehleButton(2,i,topLeftX +540,topLeftY+ i*130 +200,button_color,game);
|
||||||
|
shapes.add(button.getShape());
|
||||||
}
|
}
|
||||||
|
|
||||||
game.buttons.addAll(shapes);
|
game.buttons.addAll(shapes);
|
||||||
@@ -175,6 +178,35 @@ public class Muehle extends Application {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawPlayerChips() {
|
||||||
|
Circle[] white_player_chips = new Circle[9];
|
||||||
|
Circle[] black_player_chips = new Circle[9];
|
||||||
|
|
||||||
|
Color stroke_color = Color.BLACK;
|
||||||
|
double stroke_width = 2;
|
||||||
|
double radius = 20;
|
||||||
|
|
||||||
|
for (int i = 0; i < 9; i++) {
|
||||||
|
white_player_chips[i] = new Circle(radius*2 +20,50*i+ 200,radius);
|
||||||
|
white_player_chips[i].setStroke(stroke_color);
|
||||||
|
white_player_chips[i].setStrokeWidth(stroke_width);
|
||||||
|
white_player_chips[i].setFill(Color.WHITE);
|
||||||
|
addShape(white_player_chips[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 9; i++) {
|
||||||
|
black_player_chips[i] = new Circle((1080-20) - radius*2,50*i+ 200,radius);
|
||||||
|
black_player_chips[i].setStroke(stroke_color);
|
||||||
|
black_player_chips[i].setStrokeWidth(stroke_width);
|
||||||
|
black_player_chips[i].setFill(Color.BLACK);
|
||||||
|
addShape(black_player_chips[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
game.white_player_chips = white_player_chips;
|
||||||
|
game.black_player_chips = black_player_chips;
|
||||||
|
|
||||||
}
|
}
|
||||||
public void addShape(Shape newShape) {
|
public void addShape(Shape newShape) {
|
||||||
game_board.getChildren().add(newShape);
|
game_board.getChildren().add(newShape);
|
||||||
|
|||||||
79
Muehle.~ava
79
Muehle.~ava
@@ -12,6 +12,7 @@ import javafx.scene.shape.Line;
|
|||||||
import javafx.event.Event;
|
import javafx.event.Event;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
import javafx.scene.input.MouseEvent;
|
import javafx.scene.input.MouseEvent;
|
||||||
|
import javafx.scene.shape.Circle;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Beschreibung
|
* Beschreibung
|
||||||
@@ -38,7 +39,9 @@ public class Muehle extends Application {
|
|||||||
Scene scene = new Scene(root, 1080, 820);
|
Scene scene = new Scene(root, 1080, 820);
|
||||||
|
|
||||||
|
|
||||||
game.start(game_board);
|
game.start(game_board,lTop);
|
||||||
|
|
||||||
|
drawPlayerChips();
|
||||||
|
|
||||||
//lTop.setAlignment();
|
//lTop.setAlignment();
|
||||||
setTopLabel("Test Label");
|
setTopLabel("Test Label");
|
||||||
@@ -131,49 +134,77 @@ public class Muehle extends Application {
|
|||||||
Color button_color = Color.BLUE;
|
Color button_color = Color.BLUE;
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
MuehleButton button = new MuehleButton(0,i,topLeftX,topLeftY+ i*325,button_color,game);
|
MuehleButton button = new MuehleButton(0,i,topLeftX,topLeftY+ i*325,button_color,game);
|
||||||
shapes.add(button.getShape());
|
shapes.add(button.getShape());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
MuehleButton button = new MuehleButton(1,i,topRightX -230,topLeftY+ i*100,button_color,game);
|
MuehleButton button = new MuehleButton(1,i,topRightX -230,topLeftY+ i*100,button_color,game);
|
||||||
shapes.add(button.getShape());
|
shapes.add(button.getShape());
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
|
||||||
MuehleButton button = new MuehleButton(2,i,topRightX + 140,topLeftY+ i*325,button_color,game);
|
|
||||||
shapes.add(button.getShape());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
|
||||||
MuehleButton button = new MuehleButton(0,i,topLeftX + 100,topLeftY+ i*220 +100,button_color,game);
|
|
||||||
shapes.add(button.getShape());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
MuehleButton button = new MuehleButton(2,i,topRightX +40,topLeftY+ i*220 +100,button_color,game);
|
MuehleButton button = new MuehleButton(2,i,topRightX + 140,topLeftY+ i*325,button_color,game);
|
||||||
shapes.add(button.getShape());
|
shapes.add(button.getShape());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
MuehleButton button = new MuehleButton(1,i,topRightX -230,topLeftY+ i*100 +460,button_color,game);
|
MuehleButton button = new MuehleButton(0,i,topLeftX + 100,topLeftY+ i*220 +100,button_color,game);
|
||||||
shapes.add(button.getShape());
|
shapes.add(button.getShape());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
MuehleButton button = new MuehleButton(0,i,topLeftX +200,topLeftY+ i*130 +200,button_color,game);
|
MuehleButton button = new MuehleButton(2,i,topRightX +40,topLeftY+ i*220 +100,button_color,game);
|
||||||
shapes.add(button.getShape());
|
shapes.add(button.getShape());
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
MuehleButton button = new MuehleButton(2,i,topLeftX +540,topLeftY+ i*130 +200,button_color,game);
|
MuehleButton button = new MuehleButton(1,i,topRightX -230,topLeftY+ i*100 +460,button_color,game);
|
||||||
shapes.add(button.getShape());
|
shapes.add(button.getShape());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
MuehleButton button = new MuehleButton(0,i,topLeftX +200,topLeftY+ i*130 +200,button_color,game);
|
||||||
|
shapes.add(button.getShape());
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
MuehleButton button = new MuehleButton(2,i,topLeftX +540,topLeftY+ i*130 +200,button_color,game);
|
||||||
|
shapes.add(button.getShape());
|
||||||
|
}
|
||||||
|
|
||||||
|
game.buttons.addAll(shapes);
|
||||||
for (int i = 0; i < shapes.size() ;i++ ) {
|
for (int i = 0; i < shapes.size() ;i++ ) {
|
||||||
board.getChildren().add(shapes.get(i));
|
board.getChildren().add(shapes.get(i));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawPlayerChips() {
|
||||||
|
Circle[] white_player_chips = new Circle[9];
|
||||||
|
Circle[] black_player_chips = new Circle[9];
|
||||||
|
|
||||||
|
Color stroke_color = Color.BLACK;
|
||||||
|
double stroke_width = 2;
|
||||||
|
double radius = 20;
|
||||||
|
|
||||||
|
for (int i = 0; i < 9; i++) {
|
||||||
|
white_player_chips[i] = new Circle(radius*2 +20,50*i+ 200,radius);
|
||||||
|
white_player_chips[i].setStroke(stroke_color);
|
||||||
|
white_player_chips[i].setStrokeWidth(stroke_width);
|
||||||
|
white_player_chips[i].setFill(Color.WHITE);
|
||||||
|
addShape(white_player_chips[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 9; i++) {
|
||||||
|
black_player_chips[i] = new Circle((1080-20) - radius*2,50*i+ 200,radius);
|
||||||
|
black_player_chips[i].setStroke(stroke_color);
|
||||||
|
black_player_chips[i].setStrokeWidth(stroke_width);
|
||||||
|
black_player_chips[i].setFill(Color.BLACK);
|
||||||
|
addShape(black_player_chips[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public void addShape(Shape newShape) {
|
public void addShape(Shape newShape) {
|
||||||
game_board.getChildren().add(newShape);
|
game_board.getChildren().add(newShape);
|
||||||
|
|||||||
Reference in New Issue
Block a user