diff --git a/code/jeu de la vie/rsrc/fxml/VueJeu.fxml b/code/jeu de la vie/rsrc/fxml/VueJeu.fxml
index 01ff821..3befbd0 100644
--- a/code/jeu de la vie/rsrc/fxml/VueJeu.fxml
+++ b/code/jeu de la vie/rsrc/fxml/VueJeu.fxml
@@ -50,12 +50,11 @@
-
+
-
+
-
diff --git a/code/jeu de la vie/src/model/Manager.java b/code/jeu de la vie/src/model/Manager.java
index ed38fd0..b916ab1 100644
--- a/code/jeu de la vie/src/model/Manager.java
+++ b/code/jeu de la vie/src/model/Manager.java
@@ -9,7 +9,6 @@ import model.boucleDeJeu.observer.ObserverBDJ;
import model.plateau.Plateau;
public class Manager implements ObserverBDJ {
- private Plateau plateau;
private ActualiseurTour actualiseurTour;
private ActualiseurCellule actualiseurCellule;
private IBoucleDeJeu boucleDeJeu;
@@ -55,7 +54,7 @@ public class Manager implements ObserverBDJ {
jeuLance = false;
}
- public void setPlateau(Plateau plateau) {
- this.plateau = plateau;
- }
+ //public void setPlateau(Plateau plateau) {
+ //this.plateau = plateau;
+ //}
}
diff --git a/code/jeu de la vie/src/model/cellule/Cellule.java b/code/jeu de la vie/src/model/cellule/Cellule.java
index f6b0bb9..b1f1bea 100644
--- a/code/jeu de la vie/src/model/cellule/Cellule.java
+++ b/code/jeu de la vie/src/model/cellule/Cellule.java
@@ -32,6 +32,7 @@ public class Cellule extends ObservableCellule {
*/
public Cellule(int x, int y) throws IllegalArgumentException {
deathColor = Color.BLACK;
+ activeColorProperty().setValue(deathColor);
position = new Position(x,y);
}
diff --git a/code/jeu de la vie/src/model/cellule/créateur/CreateurCellule.java b/code/jeu de la vie/src/model/cellule/créateur/CreateurCellule.java
index b593fd1..6f17d90 100644
--- a/code/jeu de la vie/src/model/cellule/créateur/CreateurCellule.java
+++ b/code/jeu de la vie/src/model/cellule/créateur/CreateurCellule.java
@@ -21,6 +21,10 @@ public class CreateurCellule implements ICreateurCellule {
this.h = h;
}
public ListProperty> creerCellules(){
+ return creerCellules(w, h);
+ }
+
+ public ListProperty> creerCellules(int w, int h){
ObservableList> cellsInit = FXCollections.observableArrayList();
ListProperty> cells = new SimpleListProperty<>(cellsInit);
List tmp;
@@ -33,4 +37,12 @@ public class CreateurCellule implements ICreateurCellule {
}
return cells;
}
+ public List creerLigneCellule(int longeure){
+ List cells = new LinkedList<>();
+ for(int i=0; i> grilleObs = FXCollections.observableArrayList();
private ListProperty> grille = new SimpleListProperty<>();
public ListProperty> getGrille() { return (ListProperty>) grille.get(); }
- public void setGrille(ListProperty> cells) {grille.set(cells);setLongueur(cells.size()); setLargeur(cells.size());}
- public ReadOnlyListProperty grilleProperty() { return grille; }
+ public void setGrille(ListProperty> cells) {grille.set(cells);}
+ public ReadOnlyListProperty grilleProperty() { return grille;}
public Cellule getCell(int x, int y) throws IllegalArgumentException{
if(x < 0 || y < 0) {
@@ -36,12 +37,22 @@ public class Plateau implements PrototypePlateau{
return grille.get().get(y).get(x);
}
- public Plateau(){setGrille(new SimpleListProperty<>());}
+ public void resetGrille(){
+ resetGrille(getLargeur(), getLongueur());
+ }
+ public void resetGrille(int w, int h){
+ setGrille(createurCellule.creerCellules(w, h));
+ }
+
+ public Plateau(){
+ createurCellule = new CreateurCellule(0, 0);
+ setGrille(new SimpleListProperty<>());
+ }
public Plateau(int longueur, int largeur) {
+ createurCellule = new CreateurCellule(longueur, largeur);
setLargeur(largeur);
setLongueur(longueur);
- CreateurCellule c = new CreateurCellule(longueur, largeur);
- setGrille(c.creerCellules());
+ setGrille(createurCellule.creerCellules());
}
public Plateau(int longueur, int largeur, ListProperty> cellules)
diff --git a/code/jeu de la vie/src/views/VueJeu.java b/code/jeu de la vie/src/views/VueJeu.java
index 19b1708..9b8338d 100644
--- a/code/jeu de la vie/src/views/VueJeu.java
+++ b/code/jeu de la vie/src/views/VueJeu.java
@@ -59,13 +59,12 @@ public class VueJeu {
}*/
map.getChildren().clear();
- for(int i=0; i < rowGame.getValue().intValue(); ++i) {
- for(int j=0; j < colGame.getValue().intValue(); ++j) {
+ for(int i=0; i < colGame.getValue().intValue(); ++i) {
+ for(int j=0; j < rowGame.getValue().intValue(); ++j) {
Rectangle rect = new Rectangle(15, 15, color.getValue());
- plateau = new Plateau(i,j);
- manager.setPlateau(plateau);
- //rect.fillProperty().bindBidirectional(manager.getActualiseurCellule().getArbitre().getPlateau().getCell(j, i).activeColorProperty());
- rect.setOnMouseClicked(event -> changeColor(event));
+ //manager.getActualiseurCellule().getArbitre().getPlateau().getCell(j, i).activeColorProperty().bindBidirectional(rect.fillProperty());
+ rect.fillProperty().bindBidirectional(manager.getActualiseurCellule().getArbitre().getPlateau().getCell(j, i).activeColorProperty());
+ //rect.setOnMouseClicked(event -> changeColor(event));
map.add(rect, i, j);
}
}
@@ -95,12 +94,13 @@ public class VueJeu {
public void initialize() {
manager = new Manager();
deathColor = Color.BLACK;
- rowGame.getValueFactory().valueProperty().bindBidirectional((Property) manager.getActualiseurCellule().getArbitre().getPlateau().longueurProperty());
- colGame.getValueFactory().valueProperty().bindBidirectional((Property) manager.getActualiseurCellule().getArbitre().getPlateau().largeurProperty());
+ rowGame.getValueFactory().valueProperty().bindBidirectional((Property) manager.getActualiseurCellule().getArbitre().getPlateau().largeurProperty());
+ colGame.getValueFactory().valueProperty().bindBidirectional((Property) manager.getActualiseurCellule().getArbitre().getPlateau().longueurProperty());
+ manager.getActualiseurCellule().getArbitre().getPlateau().longueurProperty().addListener((src)->resetGrid());
+ manager.getActualiseurCellule().getArbitre().getPlateau().largeurProperty().addListener((src)->resetGrid());
color.valueProperty().bindBidirectional(Cellule.livingColorProperty());
- plateau = new Plateau(rowGame.getValue().intValue(), colGame.getValue().intValue());
- createGrid();
+ // createGrid();
nbColGame.setText(colGame.getValue().toString());
nbRowGame.setText(rowGame.getValue().toString());
@@ -109,4 +109,9 @@ public class VueJeu {
public void startGame(ActionEvent actionEvent) {
manager.lancerJeu();
}
+
+ public void resetGrid(){
+ manager.getActualiseurCellule().getArbitre().getPlateau().resetGrille();
+ createGrid();
+ }
}