Korongok csinosítása, rúdra kattintás kezelése megkezdve.

This commit is contained in:
pp 2021-11-08 14:55:12 +01:00
parent f34737bd30
commit be9a61c6c9
3 changed files with 40 additions and 8 deletions

View File

@ -11,7 +11,7 @@ import javafx.scene.shape.Rectangle;
public class HanoiFormController {
private Korong kezbeKorong;
@FXML
private ResourceBundle resources;
@ -36,16 +36,30 @@ 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();
}
@ -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);

View File

@ -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() {

View File

@ -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();
}