diff --git a/src/ihm/DieImages.java b/src/ihm/DieImages.java index 0839ecf..c4d4dff 100644 --- a/src/ihm/DieImages.java +++ b/src/ihm/DieImages.java @@ -16,17 +16,41 @@ public class DieImages { final Image die5 = new Image(getClass().getResourceAsStream("ressources/img/des5.png")); final Image die6 = new Image(getClass().getResourceAsStream("ressources/img/des6.png")); + final Image dief1 = new Image(getClass().getResourceAsStream("ressources/img/desf1.png")); + final Image dief2 = new Image(getClass().getResourceAsStream("ressources/img/desf2.png")); + final Image dief3 = new Image(getClass().getResourceAsStream("ressources/img/desf3.png")); + final Image dief4 = new Image(getClass().getResourceAsStream("ressources/img/desf4.png")); + final Image[] images = new Image[6]; + int taille; - public DieImages() { - images[0] = die1; - images[1] = die2; - images[2] = die3; - images[3] = die4; - images[4] = die5; - images[5] = die6; - for (int i = 0; i < images.length; i++) { + public DieImages(int i) { + switch (i) { + case 6: + images[0] = die1; + images[1] = die2; + images[2] = die3; + images[3] = die4; + images[4] = die5; + images[5] = die6; + taille = 6; + break; + case 4: + images[0] = dief1; + images[1] = dief2; + images[2] = dief3; + images[3] = dief4; + taille = 4; + break; + default: + images[0] = die1; + images[1] = die2; + images[2] = die3; + images[3] = die4; + images[4] = die5; + images[5] = die6; + taille = 6; } } diff --git a/src/ihm/controller/LancerDes.java b/src/ihm/controller/LancerDes.java index a691e14..62f3d82 100644 --- a/src/ihm/controller/LancerDes.java +++ b/src/ihm/controller/LancerDes.java @@ -51,7 +51,7 @@ public class LancerDes { private VBox initLancerD4() { - DieImages images = new DieImages(); + DieImages images = new DieImages(4); Die die = new Die(images.getImages()); ImageView stackpane = die.getdieFace(); stackpane.setFitHeight(100); @@ -95,7 +95,7 @@ public class LancerDes { } private VBox initLancerD6() { - DieImages images = new DieImages(); + DieImages images = new DieImages(6); Die die = new Die(images.getImages()); ImageView stackpane = die.getdieFace(); stackpane.setFitHeight(100); @@ -139,9 +139,10 @@ public class LancerDes { } private VBox initLancerBoth() { - DieImages images = new DieImages(); + DieImages images = new DieImages(6); + DieImages images2 = new DieImages(4); Die die = new Die(images.getImages()); - Die die2 = new Die(images.getImages()); + Die die2 = new Die(images2.getImages()); ImageView stackpane = die.getdieFace(); ImageView stackpane2 = die2.getdieFace(); stackpane.setFitHeight(100); @@ -158,8 +159,8 @@ public class LancerDes { Random random = new Random(); Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(.1), (actionEvent) -> { - int tempRandom = random.nextInt(4)+1; - int tempRandom2 = random.nextInt(6)+1; + int tempRandom = random.nextInt(6)+1; + int tempRandom2 = random.nextInt(4)+1; die.setDieFace(tempRandom); die2.setDieFace(tempRandom2); })); @@ -168,8 +169,8 @@ public class LancerDes { timeline.play(); timeline.setOnFinished(actionEvent -> { - die.setDieFace(rolls[0]); - die2.setDieFace(rolls[1]); + die.setDieFace(rolls[1]); + die2.setDieFace(rolls[0]); int result = rolls[0]+rolls[1]; diff --git a/src/ihm/ressources/img/desf1.png b/src/ihm/ressources/img/desf1.png new file mode 100644 index 0000000..89998dc Binary files /dev/null and b/src/ihm/ressources/img/desf1.png differ diff --git a/src/ihm/ressources/img/desf2.png b/src/ihm/ressources/img/desf2.png new file mode 100644 index 0000000..b0b64cc Binary files /dev/null and b/src/ihm/ressources/img/desf2.png differ diff --git a/src/ihm/ressources/img/desf3.png b/src/ihm/ressources/img/desf3.png new file mode 100644 index 0000000..0d6d601 Binary files /dev/null and b/src/ihm/ressources/img/desf3.png differ diff --git a/src/ihm/ressources/img/desf4.png b/src/ihm/ressources/img/desf4.png new file mode 100644 index 0000000..bcc8261 Binary files /dev/null and b/src/ihm/ressources/img/desf4.png differ diff --git a/src/main/Plateau.java b/src/main/Plateau.java index 0391a27..55d7b0e 100644 --- a/src/main/Plateau.java +++ b/src/main/Plateau.java @@ -375,6 +375,7 @@ public class Plateau extends Thread{ private int rollRandom(int nb) { int roll = (int) Math.floor(Math.random() * (nb-1))+1; + System.out.println("roll" + roll); return roll; }