Korong letevésének megoldása.
This commit is contained in:
parent
be9a61c6c9
commit
370e5c65bc
|
@ -58,12 +58,35 @@ public class HanoiFormController {
|
||||||
kezbeKorong.getTlap().setLayoutY(5);
|
kezbeKorong.getTlap().setLayoutY(5);
|
||||||
felvettPane.getChildren().add(kezbeKorong.getTlap());
|
felvettPane.getChildren().add(kezbeKorong.getTlap());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (r.addKorong(kezbeKorong)) {
|
||||||
|
kezbeKorong = null;
|
||||||
|
egyRudRajzolas(r);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//rudRajzolas();
|
//rudRajzolas();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
private void egyRudRajzolas(Rud r) {
|
||||||
|
double y = jatekTerulet.getHeight();
|
||||||
|
double rx1 = r.getTlap().getLayoutX();
|
||||||
|
double w = r.getSzelesseg();
|
||||||
|
for (int kix=0; kix < r.getKorongok().size(); kix++) {
|
||||||
|
Korong k = r.getKorongok().get(kix);
|
||||||
|
double kx = rx1-(k.getSzelesseg()/2-w/2);
|
||||||
|
double ky = (y-15)-((kix+1)*k.getMagassag());
|
||||||
|
Rectangle tlap = k.getTlap();
|
||||||
|
tlap.setLayoutX(kx);
|
||||||
|
tlap.setLayoutY(ky);
|
||||||
|
if (! jatekTerulet.getChildren().contains(tlap)) {
|
||||||
|
jatekTerulet.getChildren().add(tlap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
void initialize() {
|
void initialize() {
|
||||||
assert elsoRudRect != null : "fx:id=\"elsoRudRect\" was not injected: check your FXML file 'hanoi_form2.fxml'.";
|
assert elsoRudRect != null : "fx:id=\"elsoRudRect\" was not injected: check your FXML file 'hanoi_form2.fxml'.";
|
||||||
assert masodikRudRect != null : "fx:id=\"masodikRudRect\" was not injected: check your FXML file 'hanoi_form2.fxml'.";
|
assert masodikRudRect != null : "fx:id=\"masodikRudRect\" was not injected: check your FXML file 'hanoi_form2.fxml'.";
|
||||||
|
@ -117,15 +140,11 @@ public class HanoiFormController {
|
||||||
harmadikRudRect.setLayoutY(ry3);
|
harmadikRudRect.setLayoutY(ry3);
|
||||||
harmadikRudRect.setWidth(w);
|
harmadikRudRect.setWidth(w);
|
||||||
harmadikRudRect.setHeight(rh);
|
harmadikRudRect.setHeight(rh);
|
||||||
for (int kix=0; kix < r1.getKorongok().size(); kix++) {
|
|
||||||
Korong k = r1.getKorongok().get(kix);
|
egyRudRajzolas(r1);
|
||||||
double kx = rx1-(k.getSzelesseg()/2-w/2);
|
egyRudRajzolas(r2);
|
||||||
double ky = (y-15)-((kix+1)*k.getMagassag());
|
egyRudRajzolas(r3);
|
||||||
Rectangle tlap = k.getTlap();
|
|
||||||
tlap.setLayoutX(kx);
|
|
||||||
tlap.setLayoutY(ky);
|
|
||||||
jatekTerulet.getChildren().add(tlap);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,12 @@ public class Rud {
|
||||||
korongok = new ArrayList<Korong>();
|
korongok = new ArrayList<Korong>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addKorong(Korong k) {
|
public boolean addKorong(Korong k) {
|
||||||
//TODO ellenőrizni, hogy ne legyen nagyobb a korong a legfelsőnél
|
if (korongok.isEmpty() || k.getSzelesseg()<korongok.get(korongok.size()-1).getSzelesseg()) {
|
||||||
korongok.add(k);
|
korongok.add(k);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Korong elveszKorong() {
|
public Korong elveszKorong() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user