|
|
@ -2,14 +2,11 @@ package views;
|
|
|
|
|
|
|
|
|
|
|
|
import javafx.beans.property.Property;
|
|
|
|
import javafx.beans.property.Property;
|
|
|
|
import javafx.event.ActionEvent;
|
|
|
|
import javafx.event.ActionEvent;
|
|
|
|
import javafx.event.EventHandler;
|
|
|
|
|
|
|
|
import javafx.fxml.FXML;
|
|
|
|
import javafx.fxml.FXML;
|
|
|
|
import javafx.scene.Node;
|
|
|
|
|
|
|
|
import javafx.scene.control.Button;
|
|
|
|
import javafx.scene.control.Button;
|
|
|
|
import javafx.scene.control.ColorPicker;
|
|
|
|
import javafx.scene.control.ColorPicker;
|
|
|
|
import javafx.scene.control.Label;
|
|
|
|
import javafx.scene.control.Label;
|
|
|
|
import javafx.scene.control.Spinner;
|
|
|
|
import javafx.scene.control.Spinner;
|
|
|
|
import javafx.scene.input.MouseEvent;
|
|
|
|
|
|
|
|
import javafx.scene.layout.GridPane;
|
|
|
|
import javafx.scene.layout.GridPane;
|
|
|
|
import javafx.scene.paint.Color;
|
|
|
|
import javafx.scene.paint.Color;
|
|
|
|
import javafx.scene.shape.Rectangle;
|
|
|
|
import javafx.scene.shape.Rectangle;
|
|
|
@ -51,34 +48,34 @@ public class VueJeu {
|
|
|
|
|
|
|
|
|
|
|
|
public void createGrid() {
|
|
|
|
public void createGrid() {
|
|
|
|
map.getChildren().clear();
|
|
|
|
map.getChildren().clear();
|
|
|
|
for(int i=0; i < colGame.getValue().intValue(); ++i) {
|
|
|
|
for(int i=0; i < rowGame.getValue().intValue(); ++i) {
|
|
|
|
for(int j=0; j < rowGame.getValue().intValue(); ++j) {
|
|
|
|
for(int j=0; j < colGame.getValue().intValue(); ++j) {
|
|
|
|
Rectangle rect = new Rectangle(15, 15, color.getValue());
|
|
|
|
Rectangle rect = new Rectangle(15, 15, color.getValue());
|
|
|
|
Cellule c = manager.getActualiseurCellule().getArbitre().getPlateau().getCell(j, i);
|
|
|
|
Cellule c = manager.getActualiseurCellule().getArbitre().getPlateau().getCell(j, i);
|
|
|
|
rect.fillProperty().bindBidirectional(c.activeColorProperty());
|
|
|
|
rect.fillProperty().bindBidirectional(c.activeColorProperty());
|
|
|
|
rect.setOnMouseClicked((src)->manager.inverserEtatCellule(c));
|
|
|
|
rect.setOnMouseClicked((src)->manager.inverserEtatCellule(c));
|
|
|
|
map.add(rect, i, j);
|
|
|
|
map.add(rect, j, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void generateraRandom() {
|
|
|
|
public void generateraRandom() {
|
|
|
|
resetGrid();
|
|
|
|
resetGrid();
|
|
|
|
int largeur = manager.getActualiseurCellule().getArbitre().getPlateau().getLargeur();
|
|
|
|
int ligne = manager.getActualiseurCellule().getArbitre().getPlateau().getLigne();
|
|
|
|
int longueur = manager.getActualiseurCellule().getArbitre().getPlateau().getLongueur();
|
|
|
|
int colone = manager.getActualiseurCellule().getArbitre().getPlateau().getColone();
|
|
|
|
for(int i=0; i<(longueur+largeur)/2; ++i) {
|
|
|
|
for(int i=0; i<(colone+ligne)/2; ++i) {
|
|
|
|
Random random = new Random();
|
|
|
|
Random random = new Random();
|
|
|
|
manager.getActualiseurCellule().getArbitre().getPlateau().getCell(random.nextInt(longueur), random.nextInt(largeur)).setAlive(true);
|
|
|
|
manager.getActualiseurCellule().getArbitre().getPlateau().getCell(random.nextInt(colone), random.nextInt(ligne)).setAlive(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void initialize() {
|
|
|
|
public void initialize() {
|
|
|
|
manager = new Manager();
|
|
|
|
manager = new Manager();
|
|
|
|
deathColor = Color.BLACK;
|
|
|
|
deathColor = Color.BLACK;
|
|
|
|
rowGame.getValueFactory().valueProperty().bindBidirectional((Property) manager.getActualiseurCellule().getArbitre().getPlateau().largeurProperty());
|
|
|
|
rowGame.getValueFactory().valueProperty().bindBidirectional((Property) manager.getActualiseurCellule().getArbitre().getPlateau().ligneProperty());
|
|
|
|
colGame.getValueFactory().valueProperty().bindBidirectional((Property) manager.getActualiseurCellule().getArbitre().getPlateau().longueurProperty());
|
|
|
|
colGame.getValueFactory().valueProperty().bindBidirectional((Property) manager.getActualiseurCellule().getArbitre().getPlateau().coloneProperty());
|
|
|
|
manager.getActualiseurCellule().getArbitre().getPlateau().longueurProperty().addListener((src)->resetGrid());
|
|
|
|
manager.getActualiseurCellule().getArbitre().getPlateau().coloneProperty().addListener((src)->resetGrid());
|
|
|
|
manager.getActualiseurCellule().getArbitre().getPlateau().largeurProperty().addListener((src)->resetGrid());
|
|
|
|
manager.getActualiseurCellule().getArbitre().getPlateau().ligneProperty().addListener((src)->resetGrid());
|
|
|
|
colGame.getValueFactory().setValue(10);
|
|
|
|
colGame.getValueFactory().setValue(10);
|
|
|
|
rowGame.getValueFactory().setValue(10);
|
|
|
|
rowGame.getValueFactory().setValue(10);
|
|
|
|
|
|
|
|
|
|
|
@ -87,8 +84,8 @@ public class VueJeu {
|
|
|
|
nbColGame.setText(colGame.getValue().toString());
|
|
|
|
nbColGame.setText(colGame.getValue().toString());
|
|
|
|
nbRowGame.setText(rowGame.getValue().toString());
|
|
|
|
nbRowGame.setText(rowGame.getValue().toString());
|
|
|
|
numTour.textProperty().bind(((ActualiseurTourUnParUn)manager.getActualiseurTour()).cptTourProperty().asString());
|
|
|
|
numTour.textProperty().bind(((ActualiseurTourUnParUn)manager.getActualiseurTour()).cptTourProperty().asString());
|
|
|
|
nbColGame.textProperty().bind(manager.getActualiseurCellule().getArbitre().getPlateau().longueurProperty().asString());
|
|
|
|
nbColGame.textProperty().bind(manager.getActualiseurCellule().getArbitre().getPlateau().coloneProperty().asString());
|
|
|
|
nbRowGame.textProperty().bind(manager.getActualiseurCellule().getArbitre().getPlateau().largeurProperty().asString());
|
|
|
|
nbRowGame.textProperty().bind(manager.getActualiseurCellule().getArbitre().getPlateau().ligneProperty().asString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void startGame(ActionEvent actionEvent) {
|
|
|
|
public void startGame(ActionEvent actionEvent) {
|
|
|
|