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