Ajout de beaucoup de choses

main
ZartaX0O3 3 years ago
parent deee3a6997
commit 56934d234c

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

@ -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");

@ -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<Case> 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<diceNumber;i++){
try {
movePlayerNextCase();
personnage.sleep(800);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
};
personnage.start();
}
private Image createImage(Color color) {
WritableImage image = new WritableImage(1, 1);
image.getPixelWriter().setColor(0, 0, color);
return image ;
}
};
personnage.start();
}
}

@ -8,6 +8,8 @@ import javafx.scene.layout.GridPane;
import model.Case;
import model.Map;
import java.util.ArrayList;
public class MapController implements Initializable {
private final Map map = new Map(32,30);
@ -36,77 +38,36 @@ public class MapController implements Initializable {
private final Image w = new Image("/image/terrain/chemin.png");
private final Image x = new Image("/image/terrain/multiarbre1.png");
private final Image y = new Image("/image/terrain/multiarbre2.png");
private final Image z = new Image("/image/terrain/star.png");
private Case case1;
private final Image z = new Image("/image/terrain/pierre.png");
private final int[][] coordFirstDifficultyMap = {{0,24},{1,24},{2,24},{3,24},{4,24},{5,24},{5,23},{5,22},{5,21},{5,20},{5,19},{5,18},{6,18},{7,18},{8,18},{9,18},{10,18},{11,18},{12,18},{12,17},{12,16},{12,15},{12,14},{12,13},{12,12},{11,12},{10,12},{9,12},{8,12},{7,12},{6,12},{5,12},{4,12},{3,12},{3,11},{3,10},{3,9},{3,8},{3,7},{3,6},{3,5},{3,4},{3,3},{4,3},{5,3},{6,3},{7,3},{8,3},{9,3},{10,3},{11,3},{12,3},{13,3},{14,3},{15,3},{16,3},{17,3},{18,3},{19,3},{19,4},{19,5},{19,6},{19,7},{19,8},{19,9},{19,10},{20,10},{21,10},{22,10},{23,10},{24,10},{24,11},{24,12},{24,13},{24,14},{24,15},{24,16},{24,17},{24,18},{24,19},{24,20},{24,21},{24,22},{24,23},{24,24},{25,24},{26,24},{27,24},{28,24},{29,24}};
@Override
public void initialize(java.net.URL location, java.util.ResourceBundle resources) {
}
public void createMap(int difficulty) {
int[][] coordFirstDifficultyMap = {{0,24},{1,24},{2,24},{3,24},{4,24},{5,24},{5,23},{5,22},{5,21},{5,20},{5,19},{5,18},{6,18},{7,18},{8,18},{9,18},{10,18},{11,18},{12,18},{12,17},{12,16},{12,15},{12,14},{12,13},{12,12},{11,12},{10,12},{9,12},{8,12},{7,12},{6,12},{5,12},{4,12},{3,12},{3,11},{3,10},{3,9},{3,8},{3,7},{3,6},{3,5},{3,4},{3,3},{4,3},{5,3},{6,3},{7,3},{8,3},{9,3},{10,3},{11,3},{12,3},{13,3},{14,3},{15,3},{16,3},{17,3},{18,3},{19,3},{19,4},{19,5},{19,6},{19,7},{19,8},{19,9},{19,10},{20,10},{21,10},{22,10},{23,10},{24,10},{24,11},{24,12},{24,13},{24,14},{24,15},{24,16},{24,17},{24,18},{24,19},{24,20},{24,21},{24,22},{24,23},{24,24},{25,24},{26,24},{27,24},{28,24},{29,24}};
//int[][] coordFirstDifficultyMap = {{0,24},{1,24},{2,24},{3,24},{4,24},{5,24},{5,23},{5,22},{5,21},{5,20}};
if (difficulty == 1) {
int j = 1;
int j = 1, k;
for(int[] i : coordFirstDifficultyMap){
boolean bool = j == 1;
System.out.println("Taille case :" +coordFirstDifficultyMap.length);
if(j == coordFirstDifficultyMap.length){
case1 = new Case(j, i[0], i [1], bool, true, map);
}else{
case1 = new Case(j, i[0], i [1], bool, false, map);
}
boolean boolStart = j == 1;
boolean boolEnd = j == coordFirstDifficultyMap.length;
boolean bonus = false, malus = false;
if(difficulty == 1) k = (int) (Math.random() * 10);
else if(difficulty == 2) k = (int) (Math.random() * 8);
else k = (int) (Math.random() * 6);
if(k == 1 || k == 2) bonus = true;
else if(k == 3) malus = true;
System.out.println("X : " + i[0] + " Y : " + i[1] + " Start : " + boolStart + " End : " + boolEnd + " Bonus : " + bonus + " Malus : " + malus);
Case case1 = new Case(j, i[0], i [1], boolStart, bonus, malus, boolEnd, map);
map.addCase(case1);
j++;
}
}
if (difficulty == 2) {
Case case1 = new Case(1,2,2, true, false,map);
Case case2 = new Case(2,3,2, false, false,map);
Case case3 = new Case(3,4,2, false, false,map);
Case case4 = new Case(4,5,2, false, false,map);
Case case5 = new Case(5,5,3, false, false,map);
Case case6 = new Case(6,5,4, false, false,map);
Case case7 = new Case(7,5,5, false, false,map);
Case case8 = new Case(8,5,6, false, false,map);
Case case9 = new Case(9,5,7, false, false,map);
Case case10 = new Case(10,5,8, false, false,map);
map.addCase(case1);
map.addCase(case2);
map.addCase(case3);
map.addCase(case4);
map.addCase(case5);
map.addCase(case6);
map.addCase(case7);
map.addCase(case8);
map.addCase(case9);
map.addCase(case10);
}
if (difficulty == 3) {
Case case1 = new Case(1,2,2, true, false,map);
Case case2 = new Case(2,3,2, false, false,map);
Case case3 = new Case(3,4,2, false, false,map);
Case case4 = new Case(4,5,2, false, false,map);
Case case5 = new Case(5,5,3, false, false,map);
Case case6 = new Case(6,5,4, false, false,map);
Case case7 = new Case(7,5,5, false, false,map);
Case case8 = new Case(8,5,6, false, false,map);
Case case9 = new Case(9,5,7, false, false,map);
Case case10 = new Case(10,5,8, false, false,map);
map.addCase(case1);
map.addCase(case2);
map.addCase(case3);
map.addCase(case4);
map.addCase(case5);
map.addCase(case6);
map.addCase(case7);
map.addCase(case8);
map.addCase(case9);
map.addCase(case10);
}
if (difficulty != 1 && difficulty != 2 && difficulty != 3) {
System.out.println("Difficulty not found");
}
@ -209,6 +170,22 @@ public class MapController implements Initializable {
}
createMap(difficulty);
ArrayList<Case> 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);
}
}

@ -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++;
}

@ -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;
}
}

@ -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){

@ -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();
}
}

@ -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;
}

@ -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();
}

@ -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){

Loading…
Cancel
Save