You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.5 KiB
61 lines
1.5 KiB
package model;
|
|
|
|
import model.actualiseur.ActualiseurCellule;
|
|
import model.actualiseur.ActualiseurTour;
|
|
import model.actualiseur.ActualiseurTourUnParUn;
|
|
import model.boucleDeJeu.BoucleDeJeu30FPS;
|
|
import model.boucleDeJeu.IBoucleDeJeu;
|
|
import model.boucleDeJeu.observer.ObserverBDJ;
|
|
import model.plateau.Plateau;
|
|
|
|
public class Manager implements ObserverBDJ {
|
|
private ActualiseurTour actualiseurTour;
|
|
private ActualiseurCellule actualiseurCellule;
|
|
private IBoucleDeJeu boucleDeJeu;
|
|
private ChangeurRegle changeurRegle;
|
|
private boolean jeuLance;
|
|
|
|
public Manager(){
|
|
boucleDeJeu = new BoucleDeJeu30FPS();
|
|
changeurRegle = new ChangeurRegle();
|
|
Thread thread = new Thread(boucleDeJeu);
|
|
thread.start();
|
|
actualiseurCellule = changeurRegle.changerRegle(Regle.CONWAY_STYLE, new Plateau());
|
|
actualiseurTour = new ActualiseurTourUnParUn();
|
|
jeuLance = false;
|
|
}
|
|
|
|
@Override
|
|
public void update() {
|
|
if(jeuLance) {
|
|
deleguerChangementCellule();
|
|
actualiseurTour.changerTour();
|
|
}
|
|
}
|
|
|
|
private void deleguerChangementCellule() {
|
|
for (int y=0; y<actualiseurCellule.getArbitre().getPlateau().getLongueur(); ++y){
|
|
for(int x=0; x<actualiseurCellule.getArbitre().getPlateau().getLargeur(); ++x){
|
|
actualiseurCellule.changerCellule(x, y);
|
|
}
|
|
}
|
|
}
|
|
|
|
public ActualiseurCellule getActualiseurCellule(){
|
|
return actualiseurCellule;
|
|
}
|
|
|
|
public void lancerJeu(){
|
|
jeuLance = true;
|
|
}
|
|
|
|
public void stoperJeu(){
|
|
actualiseurTour.resetTour();
|
|
jeuLance = false;
|
|
}
|
|
|
|
//public void setPlateau(Plateau plateau) {
|
|
//this.plateau = plateau;
|
|
//}
|
|
}
|