Fix locations and add character names

This commit is contained in:
Julius de Jeu 2017-03-31 14:09:13 +02:00
parent ef96ad87cc
commit 1c281bae4f
4 changed files with 26 additions and 7 deletions

View file

@ -1,6 +1,7 @@
package nl.minkema.leendert; package nl.minkema.leendert;
import javafx.event.EventHandler; import javafx.event.EventHandler;
import javafx.scene.control.Label;
import javafx.scene.image.Image; import javafx.scene.image.Image;
import javafx.scene.image.ImageView; import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent; import javafx.scene.input.MouseEvent;
@ -53,10 +54,15 @@ public class Game extends Pane {
playerTurn.setX(1000); playerTurn.setX(1000);
playerTurn.setY(50); playerTurn.setY(50);
playerTurn.setPreserveRatio(true); playerTurn.setPreserveRatio(true);
playerTurn.setFitWidth(100); playerTurn.setFitHeight(400);
Label l = new Label();
l.setTranslateX(1035);
l.setTranslateY(370);
this.getChildren().add(playerTurn); this.getChildren().add(playerTurn);
this.getChildren().addAll(l);
Dice dice = new Dice(1100, 700); Dice dice = new Dice(1100, 700);
this.getChildren().add(dice); this.getChildren().add(dice);
@ -65,7 +71,9 @@ public class Game extends Pane {
int roll = dice.roll(); int roll = dice.roll();
p.move(roll); p.move(roll);
if (roll == 4) Player.four(); if (roll == 4) Player.four();
playerTurn.setImage(Menu.images[players.get(Player.getNextActive()).getCh()]); int next = players.get(Player.getNextActive()).getCh();
playerTurn.setImage(Menu.images[next]);
l.setText(Menu.names[next]);
Player.four(); Player.four();
})); }));
//this.setBackground(new Background(new BackgroundFill(Color.RED, null, null))); //this.setBackground(new Background(new BackgroundFill(Color.RED, null, null)));
@ -74,6 +82,7 @@ public class Game extends Pane {
} }
playerTurn.setImage(Menu.images[players.get(1).getCh()]); playerTurn.setImage(Menu.images[players.get(1).getCh()]);
l.setText(Menu.names[players.get(1).getCh()]);
} }

View file

@ -6,6 +6,7 @@ import javafx.scene.Node;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.Alert; import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType; import javafx.scene.control.ButtonType;
import javafx.scene.control.Tooltip;
import javafx.scene.image.Image; import javafx.scene.image.Image;
import javafx.scene.image.ImageView; import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent; import javafx.scene.input.MouseEvent;
@ -30,6 +31,7 @@ public class Menu extends Group {
public static Image[] images; public static Image[] images;
public static String[] names;
private static Random random = new Random(System.currentTimeMillis()); private static Random random = new Random(System.currentTimeMillis());
private int hoeveel = -1; private int hoeveel = -1;
@ -57,8 +59,6 @@ public class Menu extends Group {
menuplayer.play(); menuplayer.play();
menuplayer.play(); menuplayer.play();
menuplayer.stop();
nodes.add(view); nodes.add(view);
@ -69,12 +69,15 @@ public class Menu extends Group {
new Image("/svg/p3.svg", imagewidth, 0, true, false), new Image("/svg/p3.svg", imagewidth, 0, true, false),
new Image("/svg/p4.svg", imagewidth, 0, true, false), new Image("/svg/p4.svg", imagewidth, 0, true, false),
new Image("/svg/p5.svg", imagewidth, 0, true, false)}; new Image("/svg/p5.svg", imagewidth, 0, true, false)};
names = new String[]{"Paulus", "Pinkeltje", "Petunia", "Kwebbel", "Stuart"};
int x = 0, y = 0; int x = 0, y = 0;
for (int i1 = 0; i1 < images.length; i1++) { for (int i1 = 0; i1 < images.length; i1++) {
Image i = images[i1]; Image i = images[i1];
ImageView iv = new ImageView(i); ImageView iv = new ImageView(i);
iv.setX(750 + x); iv.setX(750 + x);
iv.setY(400 + y); iv.setY(400 + y);
Tooltip.install(iv, new Tooltip(names[i1]));
x += i.getRequestedWidth(); x += i.getRequestedWidth();
if (x > 200) { if (x > 200) {
y += 150; y += 150;
@ -100,10 +103,11 @@ public class Menu extends Group {
String meer = String.format("Er moeten nog %d mensen kiezen!", hoeveel); String meer = String.format("Er moeten nog %d mensen kiezen!", hoeveel);
Alert alert = new Alert(Alert.AlertType.NONE, hoeveel > 1 ? meer : een, ButtonType.OK); Alert alert = new Alert(Alert.AlertType.NONE, hoeveel > 1 ? meer : een, ButtonType.OK);
alert.show(); alert.show();
chosen.add(ch);
} }
} }
chosen.add(ch);
}); });
nodes.add(iv); nodes.add(iv);
} }
@ -123,11 +127,15 @@ public class Menu extends Group {
Rectangle clickable = new Rectangle(x2 - 10, locy + 125, 95 + i * 95, 150); Rectangle clickable = new Rectangle(x2 - 10, locy + 125, 95 + i * 95, 150);
clickable.setFill(Color.TRANSPARENT); clickable.setFill(Color.TRANSPARENT);
clickable.setStroke(Color.BLACK); clickable.setStroke(Color.BLACK);
clickable.setArcHeight(50);
clickable.setArcWidth(50);
final int s = i + 1; final int s = i + 1;
clickable.setOnMouseClicked(e -> { clickable.setOnMouseClicked(e -> {
hoeveel = s; hoeveel = s;
new Alert(Alert.AlertType.INFORMATION, "Alle " + hoeveel + " spelers kunnen nu een karakter kiezen. \nAls iemand de verkeerde kiest kan je opnieuw \nop de knop drukken om opnieuw te beginnen.").show(); new Alert(Alert.AlertType.INFORMATION, "Alle " + hoeveel + " spelers kunnen nu een karakter kiezen. \nAls iemand de verkeerde kiest kan je opnieuw \nop de knop drukken om opnieuw te beginnen.").show();
}); });
Tooltip tip = new Tooltip("Hier kan je op klikken");
Tooltip.install(clickable, tip);
nodes.add(clickable); nodes.add(clickable);
} }

View file

@ -112,4 +112,5 @@ public class Player {
} }
} }
} }

View file

@ -1,3 +1,4 @@
#format: nummer:x,y
0:438,52 0:438,52
1:496,53 1:496,53
2:548,53 2:548,53
@ -88,7 +89,7 @@
87:605,630 87:605,630
88:660,627 88:660,627
89:733,628 89:733,628
90:695,672 90:695,681
91:648,681 91:648,681
92:582,682 92:582,682
93:526,682 93:526,682