diff --git a/code/ressources/image/terrain/pierre.png b/code/ressources/image/terrain/pierre.png new file mode 100644 index 0000000..034a803 Binary files /dev/null and b/code/ressources/image/terrain/pierre.png differ diff --git a/code/ressources/image/terrain/star.png b/code/ressources/image/terrain/star.png deleted file mode 100644 index f710027..0000000 Binary files a/code/ressources/image/terrain/star.png and /dev/null differ diff --git a/code/src/controller/CreatureController.java b/code/src/controller/CreatureController.java index 406f881..497a850 100644 --- a/code/src/controller/CreatureController.java +++ b/code/src/controller/CreatureController.java @@ -66,7 +66,6 @@ public class CreatureController { int min = 1; double a = Math.random() * ( max - min ); int numCreature = (int) Math.round(a) + min; - System.out.println(numCreature); createCreature(numCreature); caseCreatureStart = mapCreatureController.getStartCase(); @@ -76,12 +75,10 @@ public class CreatureController { imagePath = getPath(); String pathStart = imagePath + "2.png"; - System.out.println("OUI" + pathStart); creatureImageView.setImage(new Image(pathStart)); creatureImageView.setId("creatureImageView"); creatureImageView.setFitWidth(35); creatureImageView.setFitHeight(35); - System.out.println("X :" + getX()); creatureImageView.setLayoutX(getX()*map.getSizeTile()-5); creatureImageView.setLayoutY(getY()*map.getSizeTile()-5); //levelRoot.getChildren().addAll(creatureImageView); @@ -109,7 +106,6 @@ public class CreatureController { public void movePlayerNextCase() throws InterruptedException { caseAncienne = caseActuelle; - System.out.println(caseActuelle); caseActuelle = mapCreatureController.getNextCase(caseActuelle); Timeline timelines = new Timeline(); timelines.setCycleCount(1); @@ -125,7 +121,6 @@ public class CreatureController { int tempsattente = 00; //animation déplacement vers la droite if(caseActuelle.getCoordX() > caseAncienne.getCoordX()){ - System.out.println(imagePath + "7.png"); imagePerso7 = new Image(imagePath + "7.png"); imagePerso8 = new Image(imagePath + "8.png"); imagePerso9 = new Image(imagePath + "9.png"); diff --git a/code/src/controller/GamePlayController.java b/code/src/controller/GamePlayController.java index 20ffbf7..c181b59 100644 --- a/code/src/controller/GamePlayController.java +++ b/code/src/controller/GamePlayController.java @@ -20,13 +20,15 @@ import model.Map; import java.io.IOException; import java.net.URL; +import java.util.ArrayList; import java.util.Objects; import java.util.ResourceBundle; public class GamePlayController implements Initializable { - private final int tileSize = 20 ; - private final int avancementCase = 4; + private final int avancementCase = 4; + private final PersoController persoController = new PersoController(); + private final MapController mapController = new MapController(); @FXML public ImageView persoImageView; @FXML public AnchorPane levelRoot; @@ -34,25 +36,23 @@ public class GamePlayController implements Initializable { @FXML public ImageView creatureImageView = new ImageView(); @FXML public ImageView playerImagePerso; - PersoController persoController = new PersoController(); - Case caseActuelle; - MapController mapController = new MapController(); - Case caseAncienne; - String pathPerso; - int i, diceNumber; - Thread personnage; + boolean finJeu = false; GameTime gameTime; GameLoop loop; Text textEnd; - public int difficulty; - public int perso; + public int difficulty; + public int perso; + private Case caseActuelle, caseAncienne; + private int i, diceNumber; + private Thread personnage; + private String pathPerso; - @FXML - @Override - public void initialize(URL url, ResourceBundle resourceBundle) { - } + @FXML + @Override + public void initialize(URL url, ResourceBundle resourceBundle) { + } public void gameLauncher(){ levelRoot.getChildren().addAll(mapController.mapInitialisation(this.difficulty), persoController.playerInitialisation(this.difficulty,this.perso, mapController.getMap()), creatureImageView); @@ -90,19 +90,17 @@ public class GamePlayController implements Initializable { } } - public void movePlayerNextCase() throws InterruptedException { - persoImageView = persoController.persoImageView; - caseActuelle = persoController.getActualCase(); - Map map = mapController.getMap(); - pathPerso = persoController.getPath(); - System.out.println(pathPerso); - caseAncienne = caseActuelle; - persoController.setOldCase(caseAncienne); - System.out.println(caseActuelle); - caseActuelle = mapController.getNextCase(caseActuelle); - persoController.setActualCase(caseActuelle); - Timeline timeline = new Timeline(); - timeline.setCycleCount(1); + public void movePlayerNextCase() throws InterruptedException { + + persoImageView = persoController.persoImageView; + caseActuelle = persoController.getActualCase(); + pathPerso = persoController.getPath(); + caseAncienne = caseActuelle; + persoController.setOldCase(caseAncienne); + caseActuelle = mapController.getNextCase(caseActuelle); + persoController.setActualCase(caseActuelle); + Timeline timeline = new Timeline(); + timeline.setCycleCount(1); int time1 = 100; int time2 = 200; @@ -270,7 +268,7 @@ public class GamePlayController implements Initializable { })); timeline.play(); } - if(caseActuelle.isEnd() == true){ + if(caseActuelle.isEnd()){ textEnd.setText("Fin"); finJeu = true; timer(); @@ -281,50 +279,52 @@ public class GamePlayController implements Initializable { } } - public void lancerDe(ActionEvent actionEvent) throws InterruptedException { - animationDe(); + + public void lancerDe() { + //Case actual = persoController.getActualCase(); + animationDe(); + //verification(actual); + } + + public void verification(Case actual) { + Map map = mapController.getMap(); + ArrayList array = map.getMap(); + actual = mapController.getCase(actual, diceNumber); + for (Case c : array) { + if (actual.getCoordX() == c.getCoordX() && actual.getCoordY() == c.getCoordY() && c.isBonus()) { + System.out.println("BONUS"); + System.out.println("X perso : " + actual.getCoordX() + " Y perso : " + actual.getCoordY() + " X perso : " + c.getCoordX() + " Y perso : " + c.getCoordY() + " Bonus : " + c.isBonus()); + } + if (actual.getCoordX() == c.getCoordX() && actual.getCoordY() == c.getCoordY() && c.isMalus()) { + System.out.println("MALUS"); + } } + } - public void animationDe() throws InterruptedException { - personnage = new Thread("personnage"){ - public void run(){ - diceNumber = 0; - i = 0; - Timeline timeline = new Timeline(); - timeline.setCycleCount(1); + public void animationDe() { + personnage = new Thread("personnage") { - for( i = 0; i<10; i++){ - diceNumber = (int) (Math.random()*6 +1); - String path = "image/dé/d" + diceNumber + ".png"; - timeline.getKeyFrames().add(new KeyFrame(Duration.millis(50*i), event -> { - de.setImage(new Image(path)); - })); - } - timeline.play(); + public void run() { + i = 0; + Timeline timeline = new Timeline(); + timeline.setCycleCount(1); + + for (i = 0; i < 10; i++) { + diceNumber = (int) (Math.random() * 6 + 1); + String path = "image/dé/d" + diceNumber + ".png"; + timeline.getKeyFrames().add(new KeyFrame(Duration.millis(50 * i), event -> de.setImage(new Image(path)))); + } + timeline.play(); + for (i = 0; i < diceNumber; i++) { try { - personnage.sleep(800); + movePlayerNextCase(); + sleep(800); } catch (InterruptedException e) { e.printStackTrace(); } - for(i=0;i array = map.getMap(); + + for (int y = 0 ; y < grid.length ; y++) { + for (int x = 0 ; x < grid[y].length ; x++) { + if(grid[y][x] != b) continue; + for(Case c : array) { + if (c.getCoordY() == y && c.getCoordX() == x && (c.isBonus() || c.isMalus())) { + ImageView imageView = new ImageView(z); + imageView.setFitWidth(tileSize); + imageView.setFitHeight(tileSize); + gridPane.add(imageView, x, y); + } + } + } + } + AnchorPane FirstAnchor = new AnchorPane(); FirstAnchor.getChildren().addAll(gridPane); return FirstAnchor; @@ -342,4 +319,8 @@ public class MapController implements Initializable { public Case getStartCase(){ return map.getStartCase(); } + + public Case getCase(Case c, int num){ + return map.getCase(c, num); + } } diff --git a/code/src/controller/MapCreatureController.java b/code/src/controller/MapCreatureController.java index e11113d..c735ecd 100644 --- a/code/src/controller/MapCreatureController.java +++ b/code/src/controller/MapCreatureController.java @@ -37,8 +37,7 @@ public class MapCreatureController { } for(int[] i : coordList){ boolean bool = j == 1; - System.out.println("Taille case creature :" +coordList.length); - Case case1 = new Case(j, i[0], i [1], bool, false, map); + Case case1 = new Case(j, i[0], i [1], bool,false,false, false, map); mapCreature.addCase(case1); j++; } diff --git a/code/src/controller/PersoController.java b/code/src/controller/PersoController.java index 3fbb131..1449e32 100644 --- a/code/src/controller/PersoController.java +++ b/code/src/controller/PersoController.java @@ -12,9 +12,6 @@ public class PersoController { @FXML public ImageView persoImageView; - @FXML - public ImageView playerImagePerso; - private Avatar avatar; private Case actualCase; @@ -77,8 +74,4 @@ public class PersoController { public void setOldCase(Case old){ this.oldCase = old; } - - public Case getOldCase(){ - return this.oldCase; - } } diff --git a/code/src/model/Album.java b/code/src/model/Album.java index 01b29b6..b5dc01c 100644 --- a/code/src/model/Album.java +++ b/code/src/model/Album.java @@ -16,10 +16,7 @@ public class Album { this.listeMusiques = listeMusiques; } - public void playlist() throws InterruptedException { - } - - public void play() throws InterruptedException { + public void play(){ musicThread = new Thread("musique") { public void run(){ @@ -30,7 +27,7 @@ public class Album { for (Musique musique : listeMusiques) { media = new Media(Objects.requireNonNull(getClass().getResource(musique.getPath())).toExternalForm()); mediaPlayer = new AudioClip(media.getSource()); - mediaPlayer.volumeProperty().setValue(0.025); + mediaPlayer.volumeProperty().setValue(0); mediaPlayer.play(); try { Thread.sleep(musique.getTemps()); @@ -51,7 +48,6 @@ public class Album { public void addList(Musique musique){ listeMusiques.add(musique); - System.out.println("add"); } public void removeList(Musique musique){ diff --git a/code/src/model/BonusCase.java b/code/src/model/BonusCase.java index 86174d6..434c5cd 100644 --- a/code/src/model/BonusCase.java +++ b/code/src/model/BonusCase.java @@ -2,8 +2,8 @@ package model; public class BonusCase extends Case { - public BonusCase(int idCase, int coordX, int coordY, boolean isStart, boolean isEnd, Map map, Bonus bonus) { - super(idCase, coordX, coordY, isStart, isEnd, map); + public BonusCase(int idCase, int coordX, int coordY, boolean isStart, boolean isBonus, boolean isMalus, boolean isEnd, Map map, Bonus bonus) { + super(idCase, coordX, coordY, isStart, isBonus, isMalus, isEnd, map); Bonus bonus1 = bonus.randomGet(); } } diff --git a/code/src/model/Case.java b/code/src/model/Case.java index 1562559..fe9cd51 100644 --- a/code/src/model/Case.java +++ b/code/src/model/Case.java @@ -6,14 +6,18 @@ public class Case { int coordY; boolean isStart; boolean isEnd; + boolean isMalus; + boolean isBonus; int sizeTile; - public Case(int idCase, int coordX, int coordY, boolean isStart, boolean isEnd, Map map) { + public Case(int idCase, int coordX, int coordY, boolean isStart, boolean isBonus, boolean isMalus, boolean isEnd, Map map) { this.sizeTile = map.getSizeTile(); this.idCase = idCase; this.coordX = coordX; this.coordY = coordY; this.isStart = isStart; + this.isBonus = isBonus; + this.isMalus = isMalus; this.isEnd = isEnd; } @@ -37,6 +41,14 @@ public class Case { return isEnd; } + public boolean isBonus() { + return isBonus; + } + + public boolean isMalus() { + return isMalus; + } + public void setIdCase(int idCase) { this.idCase = idCase; } diff --git a/code/src/model/MalusCase.java b/code/src/model/MalusCase.java index 2d60399..43208c5 100644 --- a/code/src/model/MalusCase.java +++ b/code/src/model/MalusCase.java @@ -2,8 +2,8 @@ package model; public class MalusCase extends Case{ - public MalusCase(int idCase, int coordX, int coordY, boolean isStart, boolean isEnd, Map map, Malus malus) { - super(idCase, coordX, coordY, isStart, isEnd, map); + public MalusCase(int idCase, int coordX, int coordY, boolean isStart, boolean isBonus, boolean isMalus, boolean isEnd, Map map, Malus malus) { + super(idCase, coordX, coordY, isStart, isBonus, isMalus, isEnd, map); Malus malus1 = malus.randomGet(); } diff --git a/code/src/model/Map.java b/code/src/model/Map.java index 5c5e699..ebb9e37 100644 --- a/code/src/model/Map.java +++ b/code/src/model/Map.java @@ -50,12 +50,23 @@ public class Map { } public Case getNextCase(Case c){ - int i; - int j; + int i,j; for(i = 0; i < this.map.size(); i++){ if(c == this.map.get(i)){ j=i+1; System.out.println("i : "+i+" j : "+j); + return this.map.get(j); + } + } + return c; + } + + + public Case getCase(Case c, int num){ + int j,i = 0; + for(Case cases : this.map){ + if(c == cases){ + j=i+num; try { return this.map.get(j); }catch (IndexOutOfBoundsException e){