From be9a61c6c9a4c2529ea9b1f28cf082d4ba0b9137 Mon Sep 17 00:00:00 2001 From: pp Date: Mon, 8 Nov 2021 14:55:12 +0100 Subject: [PATCH] =?UTF-8?q?Korongok=20csinos=C3=ADt=C3=A1sa,=20r=C3=BAdra?= =?UTF-8?q?=20kattint=C3=A1s=20kezel=C3=A9se=20megkezdve.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hanoi/HanoiFormController.java | 31 ++++++++++++++++++++++-------- src/hanoi/Korong.java | 4 ++++ src/hanoi/Rud.java | 13 +++++++++++++ 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/hanoi/HanoiFormController.java b/src/hanoi/HanoiFormController.java index 1abaaa5..e0b0c09 100644 --- a/src/hanoi/HanoiFormController.java +++ b/src/hanoi/HanoiFormController.java @@ -11,7 +11,7 @@ import javafx.scene.shape.Rectangle; public class HanoiFormController { - + private Korong kezbeKorong; @FXML private ResourceBundle resources; @@ -36,17 +36,31 @@ public class HanoiFormController { @FXML void elsoRudClick(MouseEvent event) { - + korongMozgatas(r1); } @FXML void harmadikRudClick(MouseEvent event) { - + korongMozgatas(r3); } @FXML void masodikRudClick(MouseEvent event) { - + korongMozgatas(r2); + } + + private void korongMozgatas(Rud r) { + if (kezbeKorong==null) { + if (!r.isEmpty()) { + kezbeKorong = r.elveszKorong(); + jatekTerulet.getChildren().remove(kezbeKorong.getTlap()); + kezbeKorong.getTlap().setLayoutX(150); + kezbeKorong.getTlap().setLayoutY(5); + felvettPane.getChildren().add(kezbeKorong.getTlap()); + } + } + //rudRajzolas(); + } @FXML @@ -65,7 +79,7 @@ public class HanoiFormController { private void korongGeneralas() { //System.out.println(jatekTerulet.widthProperty()); - korongSzelMax = jatekTerulet.getWidth()/3-KDIFF; + korongSzelMax = jatekTerulet.getWidth()/3-2*KDIFF; for (int i = 0; i < korongokSzama; i++) { Korong k = new Korong(szinek[i], korongSzelMax-i*KDIFF, korongMag); /* @@ -80,14 +94,15 @@ public class HanoiFormController { } private void rudRajzolas() { + double x = jatekTerulet.getWidth(); double y = jatekTerulet.getHeight(); double w = x*0.02; - double rx1 = x/4-w/2; + double rx1 = KDIFF+korongSzelMax/2-w/2; double ry1 = y/3; - double rx2 = rx1+x/4; + double rx2 = x/2-w/2; double ry2 = ry1; - double rx3 = rx2+x/4; + double rx3 = x-(KDIFF+korongSzelMax/2+w/2); double ry3 = ry1; double rh = y-15-ry1; elsoRudRect.setLayoutX(rx1); diff --git a/src/hanoi/Korong.java b/src/hanoi/Korong.java index d11a4e7..2e81284 100644 --- a/src/hanoi/Korong.java +++ b/src/hanoi/Korong.java @@ -16,6 +16,10 @@ public class Korong { this.szelesseg = szelesseg; this.magassag = magassag; tlap = new Rectangle(szelesseg, magassag, szin); + tlap.setArcHeight(magassag/2); + tlap.setArcWidth(magassag/2); + tlap.setStroke(Color.BLACK); + tlap.setStrokeWidth(1.5); } public Color getSzin() { diff --git a/src/hanoi/Rud.java b/src/hanoi/Rud.java index e446ef9..ecc9529 100644 --- a/src/hanoi/Rud.java +++ b/src/hanoi/Rud.java @@ -35,6 +35,15 @@ public class Rud { korongok.add(k); } + public Korong elveszKorong() { + if (!isEmpty()) { + Korong legfelso = korongok.get(korongok.size()-1); + korongok.remove(legfelso); + return legfelso; + } + return null; + } + public Color getSzin() { return szin; @@ -72,6 +81,10 @@ public class Rud { return korongok; } + public boolean isEmpty() { + return korongok.isEmpty(); + } +