13.10 end

This commit is contained in:
2025-10-13 12:42:00 +02:00
parent db2b030bd4
commit 16dc96bbca
16 changed files with 521 additions and 208 deletions

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
*.class
*.~fm
*.~ava
*.~d

3
.~itignore Normal file
View File

@@ -0,0 +1,3 @@
*.class
*.~fm
*.~ava

Binary file not shown.

View File

@@ -28,10 +28,10 @@ public class Chip {
public Circle circle; public Circle circle;
public int ring; public int id;
public Chip(int ring, int relX, int relY,double absX, double absY, Color color, Game game) { public Chip(int id, int relX, int relY,double absX, double absY, Color color, Game game) {
this.ring = ring; this.id = id;
relativeX = relX; relativeX = relX;
relativeY = relY; relativeY = relY;

View File

@@ -30,7 +30,9 @@ public class Chip {
public int ring; public int ring;
public Chip(int relX, int relY,double absX, double absY, Color color, Game game) { public Chip(int id, int relX, int relY,double absX, double absY, Color color, Game game) {
this.ring = ring;
relativeX = relX; relativeX = relX;
relativeY = relY; relativeY = relY;

Binary file not shown.

270
Game.java
View File

@@ -15,12 +15,24 @@ import javafx.scene.shape.Circle;
public class Game { public class Game {
public int[][] win_comb = {{0,3,6},{9,4,12}
,{18,5,21},{1,10,19},{22,13,7},{20,15,23},{11,16,14},{2,17,8}
,{0,1,2},{9,10,11},{18,19,20},{3,4,5},{12,13,14},{6,7,8},{21,22,23},{15,16,17}
};
public int[][] close_chips = {{1,3},{0,2,10},{1,17},{0,6},{3,5,9,12},{18,21}
,{3,7},{6,8},{7,17},{4,10},{9,11,19,1},{10,16},{4,13},{7,12,14,22},{13,16}
,{20,23},{15,17,11,14},{2,16,8},{3,19},{18,20,10},{19,15},{5,22},{21,13,23}
,{22,15}
};
public String currentTurnPlayer = "White"; public String currentTurnPlayer = "White";
public int game_state = 0; // 0 == players placing their chips; 1 = players moving their chips; 2 = player can remove chip public int game_state = 0; // 0 == players placing their chips; 1 = players moving their chips; 2,3 = player can remove chip
public int white_chips = 9; public int white_chips = 4;
public int black_chips = 9; public int black_chips = 4;
public ArrayList<Shape> buttons = new ArrayList<Shape>(); public int white_combos = 0;
public int black_combos = 0;
public ArrayList<MuehleButton> buttons = new ArrayList<MuehleButton>();
public ArrayList<Chip> chips = new ArrayList<Chip>(); public ArrayList<Chip> chips = new ArrayList<Chip>();
public Pane game_board; public Pane game_board;
public Chip current_selection; public Chip current_selection;
@@ -39,49 +51,164 @@ public class Game {
} }
public void chip_button_clicked(MuehleButton button) { public void chip_button_clicked(MuehleButton button) {
System.out.println("id" + button.id);
if (game_state == 0) { if (game_state == 0) {
Chip newChip; Chip newChip;
if (currentTurnPlayer == "White") { if (currentTurnPlayer == "White") {
newChip = addChip(button.ring,button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.WHITE); newChip = addChip(button.id,button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.WHITE);
white_chips--; white_chips--;
setChipCount(white_chips,"White"); setChipCount(white_chips,"White");
} }
else { else {
newChip = addChip(button.ring,button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.BLACK); newChip = addChip(button.id,button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.BLACK);
black_chips--; black_chips--;
setChipCount(white_chips,"Black"); setChipCount(white_chips,"Black");
} }
if (checkCombo(newChip)) { checkCombo(newChip);
System.out.println("Comb!"); removeChipTurn();
} // end of if(newChip); game_board.getChildren().remove(button);
game_board.getChildren().remove(button.getShape());
nextTurn();
} }
if(game_state == 1) { if(game_state == 1) {
// second state of game // second state of game
setLabelText("Second State"); if(current_selection != null) {
moveChip(current_selection, button);
}
//setLabelText("Second State");
} }
} }
public Chip addChip(int ring,int relX, int relY,double absX, double absY, Color color) { public void moveChip(Chip chip,MuehleButton target) {
Chip chip = new Chip(ring,relX,relY,absX,absY,color,this); Chip newChip = new Chip(target.id,0,0,target.absoluteX,target.absoluteY,chip.color,chip.game);
MuehleButton newButton = new MuehleButton(chip.id,0,0,chip.absoluteX, chip.absoluteY,chip.game);
buttons.add(newButton);
chips.add(newChip);
addShape(newButton.getShape());
addShape(newChip.getShape());
buttons.remove(target);
chips.remove(chip);
game_board.getChildren().remove(target.getShape());
game_board.getChildren().remove(chip.getShape());
checkCombo(newChip);
removeChipTurn();
}
public Chip addChip(int id,int relX, int relY,double absX, double absY, Color color) {
Chip chip = new Chip(id,relX,relY,absX,absY,color,this);
chips.add(chip); chips.add(chip);
addShape(chip.getShape()); addShape(chip.getShape());
return chip; return chip;
}
public void removeChip(Chip chip) {
MuehleButton newButton = new MuehleButton(chip.id,0,0,chip.absoluteX,chip.absoluteY,chip.game);
buttons.add(newButton);
game_board.getChildren().add(newButton.getShape());
chips.remove(chip);
game_board.getChildren().remove(chip.getShape());
} }
public void addShape(Shape newShape) { public void addShape(Shape newShape) {
game_board.getChildren().add(newShape); game_board.getChildren().add(newShape);
} }
public void chip_clicked(Chip chip) { public void chip_clicked(Chip chip) {
System.out.println(chip.relativeX);
if(game_state == 2 && chip.color == Color.BLACK) {
removeChip(chip);
white_combos--;
removeChipTurn();
}
else if (game_state == 3 && chip.color == Color.WHITE) {
removeChip(chip);
black_combos--;
removeChipTurn();
}
if (game_state == 1) {
if(currentTurnPlayer == "White" && chip.color == Color.WHITE) {
if(current_selection == null) {
current_selection = chip;
drawAvaibleButtons(current_selection);
}
else {
current_selection = chip;
hideAllButtons();
drawAvaibleButtons(current_selection);
} // end of if-else
}
else if (currentTurnPlayer == "Black" && chip.color == Color.BLACK){
if(current_selection == null) {
current_selection = chip;
drawAvaibleButtons(current_selection);
}
else {
current_selection = chip;
hideAllButtons();
drawAvaibleButtons(current_selection);
}
} // end of if-else
}
} }
public void hideAllButtons() {
for (int i = 0; i < buttons.size(); i++) {
buttons.get(i).setActive(false);
}
}
public void drawAvaibleButtons(Chip chip) {
ArrayList<MuehleButton> avaible_buttons = new ArrayList<MuehleButton>();
for (int i = 0; i < close_chips[chip.id].length ;i++ ) {
if (!isItTaken(close_chips[chip.id][i])) {
avaible_buttons.add(getButtonById(close_chips[chip.id][i]));
} // end of if
} // end of for
if(avaible_buttons.size() > 0) {
for (int i = 0; i < avaible_buttons.size(); i++) {
avaible_buttons.get(i).setActive(true);
} // end of for
}
}
public void removeChipTurn() {
if (white_combos > 0 || black_combos > 0) {
if (white_combos > 0) {
setLabelText("White, You can remove "+ white_combos + " Black Pieces");
game_state = 2;
}
if (black_combos > 0) {
setLabelText("Black, You can remove "+ black_combos + " White Pieces");
game_state = 3;
}
}
else {
nextTurn();
} // end of if-else
}
public void nextTurn() { public void nextTurn() {
if (white_chips == 0 && black_chips == 0) { if (white_chips == 0 && black_chips == 0) {
game_state = 1; game_state = 1;
hideAllButtons();
if (current_selection != null) {
current_selection = null;
} // end of if
} }
else {
game_state = 0;
}
if (currentTurnPlayer == "White") { if (currentTurnPlayer == "White") {
setLabelText("Black Turn"); setLabelText("Black Turn");
@@ -97,71 +224,68 @@ public class Game {
public void setLabelText(String value) { public void setLabelText(String value) {
LTop.setText(value); LTop.setText(value);
} }
public boolean checkCombo(Chip chip) { public void checkCombo(Chip chip) {
return checkCombo(chip.relativeX, chip.relativeY, chip.ring); checkCombo(chip.id);
} }
public boolean checkCombo(int relX, int relY, int ring) { public void checkCombo(int id) {
ArrayList<Chip> hChips = getHorizontalCloseChips(relX,relY,ring); for (int i = 0; i < win_comb.length ;i++ ) {
ArrayList<Chip> vChips = getVerticalCloseChips(relX,relY); for (int j = 0; j < win_comb[i].length; j++) {
if (win_comb[i][j] == id) {
Chip[] chips_to_check = {getChipById(win_comb[i][0]),getChipById(win_comb[i][1]),getChipById(win_comb[i][2])};
//System.out.println("ID: " +id + " 0:"+win_comb[i][0]+" 1:"+win_comb[i][1]+" 2:"+win_comb[i][2]);
if (checkChipsColor(chips_to_check)) {
if (getChipById(id).color == Color.WHITE) {
white_combos++;
}
else {
black_combos++;
} // end of if-else
} // end of if
}
}
}
Chip start_chip = getChipByPos(relX,relY); }
System.out.println("Size" + hChips.toString()); public boolean checkChipsColor(Chip[] chips) {
if (hChips.get(0) != null && hChips.get(1) != null ) { if (chips[0] != null && chips[1] != null && chips[2] != null) {
if (start_chip.color == hChips.get(0).color && start_chip.color == hChips.get(1).color) { if (chips[0].color == chips[1].color && chips[0].color == chips[2].color) {
return true; return true;
} }
} else {
if(vChips.get(0) != null && vChips.get(1) != null) {
if (start_chip.color == vChips.get(0).color && start_chip.color == vChips.get(1).color) { return false;
return true; }
}
}
return false;
}
public ArrayList<Chip> getHorizontalCloseChips(int relX, int relY, int ring) {
ArrayList<Chip> result = new ArrayList<Chip>();
System.out.println("Target: " + ring);
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
System.out.println("Result: " + result.toString());
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 ) {
System.out.println("X" + chips.get(i).relativeX);
return chips.get(i);
} // end of if
} }
else {
return false;
} // end of if-else
}
public Chip getChipById(int id) {
for (int i = 0; i < chips.size(); i++) {
if (chips.get(i).id == id) {
return chips.get(i);
} // end of if
} // end of for
return null;
}
public MuehleButton getButtonById(int id) {
for (int i = 0; i < buttons.size(); i++) {
if (buttons.get(i).id == id) {
return buttons.get(i);
} // end of if
} // end of for
return null; return null;
} }
public boolean isItTaken(int id) {
for (int i = 0; i < chips.size(); i++) {
if (chips.get(i).id == id) {
return true;
} // end of if
} // end of for
return false;
}
public void setChipCount(int value, String player) { public void setChipCount(int value, String player) {
System.out.println(white_chips-1); System.out.println(white_chips-1);
if (player == "White") { if (player == "White") {

272
Game.~ava
View File

@@ -4,7 +4,7 @@ import javafx.scene.layout.Pane;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.shape.Circle; import javafx.scene.shape.Circle;
import java.util.AbstractList;
/** /**
* *
* Beschreibung * Beschreibung
@@ -15,12 +15,24 @@ import java.util.AbstractList;
public class Game { public class Game {
public int[][] win_comb = {{0,3,6},{9,4,12}
,{18,5,21},{1,10,19},{22,13,7},{20,15,23},{11,16,14},{2,17,8}
,{0,1,2},{9,10,11},{18,19,20},{3,4,5},{12,13,14},{6,7,8},{21,22,23},{15,16,17}
};
public int[][] close_chips = {{1,3},{0,2,10},{1,17},{0,6},{3,5,9,12},{18,21}
,{3,7},{6,8},{7,17},{4,10},{9,11,19,1},{10,16},{4,13},{7,12,14,22},{13,16}
,{20,23},{15,17,11,14},{2,16,8},{3,19},{18,20,10},{19,15},{5,22},{21,13,23}
,{22,15}
};
public String currentTurnPlayer = "White"; public String currentTurnPlayer = "White";
public int game_state = 0; // 0 == players placing their chips; 1 = players moving their chips; 2 = player can remove chip public int game_state = 0; // 0 == players placing their chips; 1 = players moving their chips; 2,3 = player can remove chip
public int white_chips = 9; public int white_chips = 4;
public int black_chips = 9; public int black_chips = 4;
public ArrayList<Shape> buttons = new ArrayList<Shape>(); public int white_combos = 0;
public int black_combos = 0;
public ArrayList<MuehleButton> buttons = new ArrayList<MuehleButton>();
public ArrayList<Chip> chips = new ArrayList<Chip>(); public ArrayList<Chip> chips = new ArrayList<Chip>();
public Pane game_board; public Pane game_board;
public Chip current_selection; public Chip current_selection;
@@ -39,49 +51,164 @@ public class Game {
} }
public void chip_button_clicked(MuehleButton button) { public void chip_button_clicked(MuehleButton button) {
System.out.println("id" + button.id);
if (game_state == 0) { if (game_state == 0) {
Chip newChip; Chip newChip;
if (currentTurnPlayer == "White") { if (currentTurnPlayer == "White") {
newChip = addChip(button.ring,button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.WHITE); newChip = addChip(button.id,button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.WHITE);
white_chips--; white_chips--;
setChipCount(white_chips,"White"); setChipCount(white_chips,"White");
} }
else { else {
newChip = addChip(button.ring,button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.BLACK); newChip = addChip(button.id,button.relativeX,button.relativeY,button.absoluteX,button.absoluteY,Color.BLACK);
black_chips--; black_chips--;
setChipCount(white_chips,"Black"); setChipCount(white_chips,"Black");
} }
if (checkCombo(newChip)) { checkCombo(newChip);
System.out.println("Comb!"); removeChipTurn();
} // end of if(newChip); game_board.getChildren().remove(button);
game_board.getChildren().remove(button.getShape());
nextTurn();
} }
if(game_state == 1) { if(game_state == 1) {
// second state of game // second state of game
setLabelText("Second State"); if(current_selection != null) {
moveChip(current_selection, button);
}
//setLabelText("Second State");
} }
} }
public Chip addChip(int ring,int relX, int relY,double absX, double absY, Color color) { public void moveChip(Chip chip,MuehleButton target) {
Chip chip = new Chip(ring,relX,relY,absX,absY,color,this); Chip newChip = new Chip(target.id,0,0,target.absoluteX,target.absoluteY,chip.color,chip.game);
MuehleButton newButton = new MuehleButton(chip.id,0,0,chip.absoluteX, chip.absoluteY,chip.game);
buttons.add(newButton);
chips.add(newChip);
addShape(newButton.getShape());
addShape(newChip.getShape());
buttons.remove(target);
chips.remove(chip);
game_board.getChildren().remove(target.getShape());
game_board.getChildren().remove(chip.getShape());
checkCombo(newChip);
removeChipTurn();
}
public Chip addChip(int id,int relX, int relY,double absX, double absY, Color color) {
Chip chip = new Chip(id,relX,relY,absX,absY,color,this);
chips.add(chip); chips.add(chip);
addShape(chip.getShape()); addShape(chip.getShape());
return chip; return chip;
}
public void removeChip(Chip chip) {
MuehleButton newButton = new MuehleButton(chip.id,0,0,chip.absoluteX,chip.absoluteY,chip.game);
buttons.add(newButton);
game_board.getChildren().add(newButton.getShape());
chips.remove(chip);
game_board.getChildren().remove(chip.getShape());
} }
public void addShape(Shape newShape) { public void addShape(Shape newShape) {
game_board.getChildren().add(newShape); game_board.getChildren().add(newShape);
} }
public void chip_clicked(Chip chip) { public void chip_clicked(Chip chip) {
System.out.println(chip.relativeX);
if(game_state == 2 && chip.color == Color.BLACK) {
removeChip(chip);
white_combos--;
removeChipTurn();
}
else if (game_state == 3 && chip.color == Color.WHITE) {
removeChip(chip);
black_combos--;
removeChipTurn();
}
if (game_state == 1) {
if(currentTurnPlayer == "White" && chip.color == Color.WHITE) {
if(current_selection == null) {
current_selection = chip;
drawAvaibleButtons(current_selection);
}
else {
current_selection = chip;
hideAllButtons();
drawAvaibleButtons(current_selection);
} // end of if-else
}
else if (currentTurnPlayer == "Black" && chip.color == Color.BLACK){
if(current_selection == null) {
current_selection = chip;
drawAvaibleButtons(current_selection);
}
else {
current_selection = chip;
hideAllButtons();
drawAvaibleButtons(current_selection);
}
} // end of if-else
}
} }
public void hideAllButtons() {
for (int i = 0; i < buttons.size(); i++) {
buttons.get(i).setActive(false);
}
}
public void drawAvaibleButtons(Chip chip) {
ArrayList<MuehleButton> avaible_buttons = new ArrayList<MuehleButton>();
for (int i = 0; i < close_chips[chip.id].length ;i++ ) {
if (!isItTaken(close_chips[chip.id][i])) {
avaible_buttons.add(getButtonById(close_chips[chip.id][i]));
} // end of if
} // end of for
if(avaible_buttons.size() > 0) {
for (int i = 0; i < avaible_buttons.size(); i++) {
avaible_buttons.get(i).setActive(true);
} // end of for
}
}
public void removeChipTurn() {
if (white_combos > 0 || black_combos > 0) {
if (white_combos > 0) {
setLabelText("White, You can remove "+ white_combos + " Black Pieces");
game_state = 2;
}
if (black_combos > 0) {
setLabelText("Black, You can remove "+ black_combos + " White Pieces");
game_state = 3;
}
}
else {
nextTurn();
} // end of if-else
}
public void nextTurn() { public void nextTurn() {
if (white_chips == 0 && black_chips == 0) { if (white_chips == 0 && black_chips == 0) {
game_state = 1; game_state = 1;
hideAllButtons();
if (current_selection != null) {
current_selection = null;
} // end of if
} }
else {
game_state = 0;
}
if (currentTurnPlayer == "White") { if (currentTurnPlayer == "White") {
setLabelText("Black Turn"); setLabelText("Black Turn");
@@ -97,71 +224,68 @@ public class Game {
public void setLabelText(String value) { public void setLabelText(String value) {
LTop.setText(value); LTop.setText(value);
} }
public boolean checkCombo(Chip chip) { public void checkCombo(Chip chip) {
return checkCombo(chip.relativeX, chip.relativeY, chip.ring); checkCombo(chip.id);
} }
public boolean checkCombo(int relX, int relY, int ring) { public void checkCombo(int id) {
ArrayList<Chip> hChips = getHorizontalCloseChips(relX,relY,ring); for (int i = 0; i < win_comb.length ;i++ ) {
ArrayList<Chip> vChips = getVerticalCloseChips(relX,relY); for (int j = 0; j < win_comb[i].length; j++) {
if (win_comb[i][j] == id) {
Chip[] chips_to_check = {getChipById(win_comb[i][0]),getChipById(win_comb[i][1]),getChipById(win_comb[i][2])};
//System.out.println("ID: " +id + " 0:"+win_comb[i][0]+" 1:"+win_comb[i][1]+" 2:"+win_comb[i][2]);
if (checkChipsColor(chips_to_check)) {
if (getChipById(id).color == Color.WHITE) {
white_combos++;
}
else {
black_combos++;
} // end of if-else
} // end of if
}
}
}
Chip start_chip = getChipByPos(relX,relY); }
System.out.println("Size" + hChips.toString()); public boolean checkChipsColor(Chip[] chips) {
if (hChips.get(0) != null && hChips.get(1) != null ) { if (chips[0] != null && chips[1] != null && chips[2] != null) {
if (start_chip.color == hChips.get(0).color && start_chip.color == hChips.get(1).color) { if (chips[0].color == chips[1].color && chips[0].color == chips[2].color) {
return true; return true;
} }
} else {
if(vChips.get(0) != null && vChips.get(1) != null) {
if (start_chip.color == vChips.get(0).color && start_chip.color == vChips.get(1).color) { return false;
return true; }
}
}
return false;
}
public ArrayList<Chip> getHorizontalCloseChips(int relX, int relY, int ring) {
ArrayList<Chip> result = new ArrayList<Chip>();
System.out.println("Target: " + ring);
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
System.out.println("Result: " + result.toString());
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 ) {
System.out.println("X" + chips.get(i).relativeX);
return chips.get(i);
} // end of if
} }
else {
return false;
} // end of if-else
}
public Chip getChipById(int id) {
for (int i = 0; i < chips.size(); i++) {
if (chips.get(i).id == id) {
return chips.get(i);
} // end of if
} // end of for
return null;
}
public MuehleButton getButtonById(int id) {
for (int i = 0; i < buttons.size(); i++) {
if (buttons.get(i).id == id) {
return buttons.get(i);
} // end of if
} // end of for
return null; return null;
} }
public boolean isItTaken(int id) {
for (int i = 0; i < chips.size(); i++) {
if (chips.get(i).id == id) {
return true;
} // end of if
} // end of for
return false;
}
public void setChipCount(int value, String player) { public void setChipCount(int value, String player) {
System.out.println(white_chips-1); System.out.println(white_chips-1);
if (player == "White") { if (player == "White") {

Binary file not shown.

View File

@@ -144,52 +144,61 @@ public class Muehle extends Application {
} }
public void drawMuehleButtons(Pane board, double topLeftX,double topLeftY,double topRightX,double topRightY) { public void drawMuehleButtons(Pane board, double topLeftX,double topLeftY,double topRightX,double topRightY) {
ArrayList<Shape> shapes = new ArrayList<Shape>(); ArrayList<MuehleButton> buttons = new ArrayList<MuehleButton>();
Color button_color = Color.BLUE;
int id_count = 0;
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(0,0,i,topLeftX,topLeftY+ i*325,button_color,game); MuehleButton button = new MuehleButton(id_count,0,i,topLeftX,topLeftY+ i*325,game);
shapes.add(button.getShape()); id_count++;
buttons.add(button);
} }
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(i,1,i,topRightX -230,topLeftY+ i*100,button_color,game); MuehleButton button = new MuehleButton(id_count,1,i,topRightX -230,topLeftY+ i*100,game);
shapes.add(button.getShape()); id_count++;
buttons.add(button);
} }
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(0,2,i,topRightX + 140,topLeftY+ i*325,button_color,game); MuehleButton button = new MuehleButton(id_count,2,i,topRightX + 140,topLeftY+ i*325,game);
shapes.add(button.getShape()); id_count++;
buttons.add(button);
} }
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(1,0,i,topLeftX + 100,topLeftY+ i*220 +100,button_color,game); MuehleButton button = new MuehleButton(id_count,0,i,topLeftX + 100,topLeftY+ i*220 +100,game);
shapes.add(button.getShape()); id_count++;
buttons.add(button);
} }
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(1,2,i,topRightX +40,topLeftY+ i*220 +100,button_color,game); MuehleButton button = new MuehleButton(id_count,2,i,topRightX +40,topLeftY+ i*220 +100,game);
shapes.add(button.getShape()); id_count++;
buttons.add(button);
} }
for (int i = 2; i >=0; i--) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(i,1,i,topRightX -230,topLeftY+ i*100 + 360,button_color,game); MuehleButton button = new MuehleButton(id_count,1,i,topRightX -230,topLeftY+ i*100 + 360,game);
shapes.add(button.getShape()); id_count++;
buttons.add(button);
} }
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(2,0,i,topLeftX +200,topLeftY+ i*130 +200,button_color,game); MuehleButton button = new MuehleButton(id_count,0,i,topLeftX +200,topLeftY+ i*130 +200,game);
shapes.add(button.getShape()); id_count++;
buttons.add(button);
} }
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(0,2,i,topLeftX +540,topLeftY+ i*130 +200,button_color,game); MuehleButton button = new MuehleButton(id_count,2,i,topLeftX +540,topLeftY+ i*130 +200,game);
shapes.add(button.getShape()); id_count++;
buttons.add(button);
} }
game.buttons.addAll(shapes); game.buttons.addAll(buttons);
for (int i = 0; i < shapes.size() ;i++ ) { for (int i = 0; i < buttons.size() ;i++ ) {
board.getChildren().add(shapes.get(i)); board.getChildren().add(buttons.get(i).getShape());
} }

View File

@@ -144,52 +144,61 @@ public class Muehle extends Application {
} }
public void drawMuehleButtons(Pane board, double topLeftX,double topLeftY,double topRightX,double topRightY) { public void drawMuehleButtons(Pane board, double topLeftX,double topLeftY,double topRightX,double topRightY) {
ArrayList<Shape> shapes = new ArrayList<Shape>(); ArrayList<MuehleButton> buttons = new ArrayList<MuehleButton>();
Color button_color = Color.BLUE;
int id_count = 0;
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(0,0,i,topLeftX,topLeftY+ i*325,button_color,game); MuehleButton button = new MuehleButton(id_count,0,i,topLeftX,topLeftY+ i*325,game);
shapes.add(button.getShape()); id_count++;
buttons.add(button);
} }
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(i,1,i,topRightX -230,topLeftY+ i*100,button_color,game); MuehleButton button = new MuehleButton(id_count,1,i,topRightX -230,topLeftY+ i*100,game);
shapes.add(button.getShape()); id_count++;
buttons.add(button);
} }
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(0,2,i,topRightX + 140,topLeftY+ i*325,button_color,game); MuehleButton button = new MuehleButton(id_count,2,i,topRightX + 140,topLeftY+ i*325,game);
shapes.add(button.getShape()); id_count++;
buttons.add(button);
} }
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(1,0,i,topLeftX + 100,topLeftY+ i*220 +100,button_color,game); MuehleButton button = new MuehleButton(id_count,0,i,topLeftX + 100,topLeftY+ i*220 +100,game);
shapes.add(button.getShape()); id_count++;
buttons.add(button);
} }
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(1,2,i,topRightX +40,topLeftY+ i*220 +100,button_color,game); MuehleButton button = new MuehleButton(id_count,2,i,topRightX +40,topLeftY+ i*220 +100,game);
shapes.add(button.getShape()); id_count++;
buttons.add(button);
} }
for (int i = 2; i >=0; i--) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(i,1,i,topRightX -230,topLeftY+ i*100 + 360,button_color,game); MuehleButton button = new MuehleButton(id_count,1,i,topRightX -230,topLeftY+ i*100 + 360,game);
shapes.add(button.getShape()); id_count++;
buttons.add(button);
} }
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(2,0,i,topLeftX +200,topLeftY+ i*130 +200,button_color,game); MuehleButton button = new MuehleButton(id_count,0,i,topLeftX +200,topLeftY+ i*130 +200,game);
shapes.add(button.getShape()); id_count++;
buttons.add(button);
} }
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MuehleButton button = new MuehleButton(0,2,i,topLeftX +540,topLeftY+ i*130 +200,button_color,game); MuehleButton button = new MuehleButton(id_count,2,i,topLeftX +540,topLeftY+ i*130 +200,game);
shapes.add(button.getShape()); id_count++;
buttons.add(button);
} }
game.buttons.addAll(shapes); game.buttons.addAll(buttons);
for (int i = 0; i < shapes.size() ;i++ ) { for (int i = 0; i < buttons.size() ;i++ ) {
board.getChildren().add(shapes.get(i)); board.getChildren().add(buttons.get(i).getShape());
} }

View File

@@ -2,14 +2,18 @@ object FGUIForm: TFXGUIForm
Tag = 180 Tag = 180
Left = 240 Left = 240
Top = 154 Top = 154
Margins.Left = 6
Margins.Top = 6
Margins.Right = 6
Margins.Bottom = 6
BorderIcons = [biSystemMenu] BorderIcons = [biSystemMenu]
Caption = 'Muehle' Caption = 'Muehle'
ClientHeight = 227 ClientHeight = 454
ClientWidth = 270 ClientWidth = 540
Color = clBtnFace Color = clBtnFace
Font.Charset = DEFAULT_CHARSET Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText Font.Color = clWindowText
Font.Height = -12 Font.Height = -24
Font.Name = 'Segoe UI' Font.Name = 'Segoe UI'
Font.Style = [] Font.Style = []
FormStyle = fsStayOnTop FormStyle = fsStayOnTop
@@ -40,7 +44,8 @@ object FGUIForm: TFXGUIForm
MinHeight = 0 MinHeight = 0
MinWidth = 0 MinWidth = 0
showing = '' showing = ''
TextHeight = 15 PixelsPerInch = 192
TextHeight = 32
object GNUgettextMarker: TGnuGettextComponentMarker object GNUgettextMarker: TGnuGettextComponentMarker
end end
end end

Binary file not shown.

Binary file not shown.

View File

@@ -14,16 +14,18 @@ public class MuehleButton {
public double absoluteX; public double absoluteX;
public double absoluteY; public double absoluteY;
public Color color; public Color color = Color.BLUE;
public double radius; public double radius;
public Circle circle; public Circle circle;
public int ring; public int id;
public MuehleButton(int ring,int relX, int relY, double absX, double absY, Color color, Game game) { public boolean isActive = true;
this.ring = ring;
public MuehleButton(int id,int relX, int relY, double absX, double absY, Game game) {
this.id = id;
relativeX = relX; relativeX = relX;
relativeY = relY; relativeY = relY;
@@ -39,17 +41,30 @@ public class MuehleButton {
this.game = game; this.game = game;
circle.addEventHandler(MouseEvent.MOUSE_RELEASED, mouse_click_target); circle.addEventHandler(MouseEvent.MOUSE_RELEASED, mouse_click_target);
setActive(true);
} }
public Shape getShape() { public Shape getShape() {
return circle; return circle;
} }
public void setActive(boolean value) {
isActive = value;
if(value == true) {
circle.setFill(this.color);
}
else {
//circle.setFill(Color.rgb(0,0,0,0));
circle.setFill(Color.rgb(0,255,0));
}
}
EventHandler<MouseEvent> mouse_click_target = new EventHandler<MouseEvent>() { EventHandler<MouseEvent> mouse_click_target = new EventHandler<MouseEvent>() {
public void handle(MouseEvent event) { public void handle(MouseEvent event) {
System.out.println("Button Clicked!"); if (isActive) {
MouseClick(); MouseClick();
} // end of if
} }
}; };

View File

@@ -14,13 +14,19 @@ public class MuehleButton {
public double absoluteX; public double absoluteX;
public double absoluteY; public double absoluteY;
public Color color; public Color color = Color.BLUE;
public double radius; public double radius;
public Circle circle; public Circle circle;
public MuehleButton(int ring,int relX, int relY, double absX, double absY, Color color, Game game) { public int id;
public boolean isActive = true;
public MuehleButton(int id,int relX, int relY, double absX, double absY, Game game) {
this.id = id;
relativeX = relX; relativeX = relX;
relativeY = relY; relativeY = relY;
@@ -35,17 +41,29 @@ public class MuehleButton {
this.game = game; this.game = game;
circle.addEventHandler(MouseEvent.MOUSE_RELEASED, mouse_click_target); circle.addEventHandler(MouseEvent.MOUSE_RELEASED, mouse_click_target);
setActive(true);
} }
public Shape getShape() { public Shape getShape() {
return circle; return circle;
} }
public void setActive(boolean value) {
isActive = value;
if(value == true) {
circle.setFill(this.color);
}
else {
//circle.setFill(Color.rgb(0,0,0,0));
circle.setFill(Color.rgb(0,255,0));
}
}
EventHandler<MouseEvent> mouse_click_target = new EventHandler<MouseEvent>() { EventHandler<MouseEvent> mouse_click_target = new EventHandler<MouseEvent>() {
public void handle(MouseEvent event) { public void handle(MouseEvent event) {
System.out.println("Button Clicked!"); System.out.println("Button Clicked!");
MouseClick(); MouseClick();
} }
}; };