Cellules random fonctinel

master
Allan POINT 4 years ago
parent 7ecfcfbffc
commit 1248ee9e74

@ -34,6 +34,7 @@ public class Cellule extends ObservableCellule {
deathColor = Color.BLACK; deathColor = Color.BLACK;
activeColorProperty().setValue(deathColor); activeColorProperty().setValue(deathColor);
position = new Position(x,y); position = new Position(x,y);
alive = new SimpleBooleanProperty(false);
} }
/** /**
@ -54,7 +55,7 @@ public class Cellule extends ObservableCellule {
*/ */
public void setAlive(Boolean alive) { public void setAlive(Boolean alive) {
notifier(this); notifier(this);
setActiveColor(alive ? (Color) getActiveColor() : deathColor); setActiveColor(alive ? (Color) getLivingColor() : deathColor);
this.alive.set(alive); this.alive.set(alive);
} }

@ -62,9 +62,7 @@ public class VueJeu {
for(int i=0; i < colGame.getValue().intValue(); ++i) { for(int i=0; i < colGame.getValue().intValue(); ++i) {
for(int j=0; j < rowGame.getValue().intValue(); ++j) { for(int j=0; j < rowGame.getValue().intValue(); ++j) {
Rectangle rect = new Rectangle(15, 15, color.getValue()); Rectangle rect = new Rectangle(15, 15, color.getValue());
//manager.getActualiseurCellule().getArbitre().getPlateau().getCell(j, i).activeColorProperty().bindBidirectional(rect.fillProperty());
rect.fillProperty().bindBidirectional(manager.getActualiseurCellule().getArbitre().getPlateau().getCell(j, i).activeColorProperty()); rect.fillProperty().bindBidirectional(manager.getActualiseurCellule().getArbitre().getPlateau().getCell(j, i).activeColorProperty());
//rect.setOnMouseClicked(event -> changeColor(event));
map.add(rect, i, j); map.add(rect, i, j);
} }
} }
@ -83,10 +81,11 @@ public class VueJeu {
public void generateraRandom() { public void generateraRandom() {
//createGrid(manager.getActualiseurCellule().getArbitre().getPlateau().getLargeur(), manager.getActualiseurCellule().getArbitre().getPlateau().getLongueur()); //createGrid(manager.getActualiseurCellule().getArbitre().getPlateau().getLargeur(), manager.getActualiseurCellule().getArbitre().getPlateau().getLongueur());
resetGrid();
int largeur = manager.getActualiseurCellule().getArbitre().getPlateau().getLargeur();
int longueur = manager.getActualiseurCellule().getArbitre().getPlateau().getLongueur();
for(int i=0; i<20; ++i) { for(int i=0; i<20; ++i) {
Random random = new Random(); Random random = new Random();
int largeur = manager.getActualiseurCellule().getArbitre().getPlateau().getLargeur();
int longueur = manager.getActualiseurCellule().getArbitre().getPlateau().getLongueur();
manager.getActualiseurCellule().getArbitre().getPlateau().getCell(random.nextInt(longueur), random.nextInt(largeur)).setAlive(true); manager.getActualiseurCellule().getArbitre().getPlateau().getCell(random.nextInt(longueur), random.nextInt(largeur)).setAlive(true);
} }
} }

Loading…
Cancel
Save