affichage mines restantes ok
This commit is contained in:
parent
e1f22fe43d
commit
63642b7146
@ -6,13 +6,17 @@ public class EtatPartie extends JPanel {
|
||||
public EtatPartie(int mines) {
|
||||
super();
|
||||
|
||||
// On défini un style et une taille à la bannière
|
||||
// On défini un style à la bannière
|
||||
this.setBackground( new Color(0, 236, 96));
|
||||
|
||||
this.setSize(200,100);
|
||||
setMinesLeft(mines);
|
||||
|
||||
}
|
||||
|
||||
// Méthode pour afficher le nombre de mines restantes
|
||||
protected void setMinesLeft(int minesLeft){
|
||||
this.removeAll();
|
||||
this.add(new MineLeft(minesLeft,this.getSize()));
|
||||
//System.out.println("Mines restantes : "+minesLeft);
|
||||
this.repaint();
|
||||
|
@ -8,6 +8,7 @@ public class Grille extends JPanel {
|
||||
private Case[] plateau;
|
||||
private int taille;
|
||||
private int mines;
|
||||
private int minesLeft;
|
||||
|
||||
// Définition du constructeur qui correspond à une grille de jeu
|
||||
public Grille(EtatPartie banniere,int lignes, int colonnes, int mines){
|
||||
@ -17,8 +18,6 @@ public class Grille extends JPanel {
|
||||
this.grilleSize = new Dimension(((screenSize.height*3/4)/lignes)*colonnes, screenSize.height*3/4 );
|
||||
Dimension caseSize = new Dimension(this.grilleSize.height/lignes,this.grilleSize.height/lignes);
|
||||
GridLayout damier = new GridLayout(lignes,colonnes);
|
||||
System.out.println("Taille des cases : "+caseSize);
|
||||
System.out.println("Taille de la Grille : "+grilleSize);
|
||||
this.setLayout(damier);
|
||||
this.setSize(grilleSize);
|
||||
this.taille=lignes*colonnes;
|
||||
@ -152,13 +151,13 @@ public class Grille extends JPanel {
|
||||
|
||||
// Méthode pour déterminer le nombre de mines restantes
|
||||
public void MinesLeft(){
|
||||
int minesLeft=this.mines;
|
||||
this.minesLeft=this.mines;
|
||||
for (int i=0;i<taille;i++){
|
||||
//System.out.println("case repéree ? == "+plateau[i].getReperee());
|
||||
if(plateau[i].getReperee()==true){
|
||||
minesLeft-=1;
|
||||
this.minesLeft-=1;
|
||||
}
|
||||
}
|
||||
this.banniere.setMinesLeft(minesLeft);
|
||||
this.banniere.setMinesLeft(this.minesLeft);
|
||||
}
|
||||
}
|
||||
|
@ -8,17 +8,15 @@ public class MineLeft extends JComponent {
|
||||
super();
|
||||
this.minesLeft = minesLeft;
|
||||
this.banniereSize=banniereSize;
|
||||
System.out.println("Mines restantes : "+this.minesLeft);
|
||||
}
|
||||
@Override
|
||||
protected void paintComponent(Graphics pinceau) {
|
||||
this.setSize(banniereSize);
|
||||
Graphics chiffre = pinceau.create();
|
||||
//Font font = new Font("Arial", Font.BOLD, banniereSize.width*1/10);
|
||||
//chiffre.setFont(font);
|
||||
//chiffre.setColor(new Color(236, 214, 0));
|
||||
//chiffre.drawString(Integer.toString(this.minesLeft),banniereSize.width*2/5,banniereSize.height/2);
|
||||
//chiffre.drawString("ALED",banniereSize.width/2,banniereSize.height/2);
|
||||
chiffre.setColor(Color.black);
|
||||
chiffre.fillRect(10, 10, 200, 100);
|
||||
Font font = new Font("Arial", Font.BOLD, banniereSize.width*1/10);
|
||||
chiffre.setFont(font);
|
||||
chiffre.setColor(new Color(0, 22, 236));
|
||||
chiffre.drawString(Integer.toString(this.minesLeft),banniereSize.width*1/5,banniereSize.height*2/3);
|
||||
System.out.println(this.getSize());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user