correction Case
This commit is contained in:
parent
fd598eeb07
commit
df2232c155
25
Case.java
25
Case.java
@ -22,10 +22,19 @@ public class Case extends JPanel {
|
|||||||
|
|
||||||
GridLayout unique = new GridLayout(1,1);
|
GridLayout unique = new GridLayout(1,1);
|
||||||
this.setLayout(unique);
|
this.setLayout(unique);
|
||||||
|
this.setBackground(new Color(70, 70, 70));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVisible(){
|
public void setVisible(){
|
||||||
this.visible=true;
|
this.visible=true;
|
||||||
|
if (this.minee == true) {
|
||||||
|
this.setBackground(new Color(236, 0, 140));
|
||||||
|
} else {
|
||||||
|
this.setBackground(new Color(80, 80, 80));
|
||||||
|
if (this.entourage>0){
|
||||||
|
this.add(new Chiffre(entourage,caseSize));
|
||||||
|
}
|
||||||
|
}
|
||||||
this.updateUI();
|
this.updateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,21 +42,7 @@ public class Case extends JPanel {
|
|||||||
return this.visible;
|
return this.visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Case getCase(){
|
|
||||||
if (this.visible == false) {
|
|
||||||
this.setBackground(new Color(70, 70, 70));
|
|
||||||
} else if (this.visible == true) {
|
|
||||||
if (this.minee == true) {
|
|
||||||
this.setBackground(new Color(236, 0, 140));
|
|
||||||
} else {
|
|
||||||
this.setBackground(new Color(80, 80, 80));
|
|
||||||
if (this.entourage>0){
|
|
||||||
this.add(new Chiffre(entourage,caseSize));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getMine(){
|
public boolean getMine(){
|
||||||
return this.minee;
|
return this.minee;
|
||||||
|
@ -3,7 +3,7 @@ import java.awt.*;
|
|||||||
|
|
||||||
// Cette classe à pour but d'afficher un menu et de réagir aux directives de l'utilisateur (lancer le jeu, le quitter...)
|
// Cette classe à pour but d'afficher un menu et de réagir aux directives de l'utilisateur (lancer le jeu, le quitter...)
|
||||||
public class FrameJeu{
|
public class FrameJeu{
|
||||||
public FrameJeu(Grille grille, int mines) {
|
public FrameJeu(Grille grille) {
|
||||||
|
|
||||||
// On récupère les dimensions de l'écran pour adapter la taille par défaut de notre fenêtre
|
// On récupère les dimensions de l'écran pour adapter la taille par défaut de notre fenêtre
|
||||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
|
@ -267,7 +267,7 @@ public class Grille extends JPanel {
|
|||||||
protected void AfficherPlateau(int taille, Dimension caseSize, int[] entourage, boolean[] minee){
|
protected void AfficherPlateau(int taille, Dimension caseSize, int[] entourage, boolean[] minee){
|
||||||
for (int i=0;i<taille;i++){
|
for (int i=0;i<taille;i++){
|
||||||
this.plateau[i]= new Case(caseSize,minee[i],entourage[i]);
|
this.plateau[i]= new Case(caseSize,minee[i],entourage[i]);
|
||||||
this.add(this.plateau[i].getCase());
|
this.add(this.plateau[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ public class Listener implements MouseListener{
|
|||||||
Case panel = (Case)evenement.getSource();
|
Case panel = (Case)evenement.getSource();
|
||||||
if ((evenement.getButton() == MouseEvent.BUTTON1)&&(panel.getVisible()==false)&&(this.marquage==0)){
|
if ((evenement.getButton() == MouseEvent.BUTTON1)&&(panel.getVisible()==false)&&(this.marquage==0)){
|
||||||
panel.setVisible();
|
panel.setVisible();
|
||||||
panel.getCase();
|
|
||||||
if (panel.getMine()==true){
|
if (panel.getMine()==true){
|
||||||
System.out.println("Perdu!");
|
System.out.println("Perdu!");
|
||||||
}
|
}
|
||||||
@ -34,16 +33,12 @@ public class Listener implements MouseListener{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void mouseEntered(MouseEvent evenement){
|
public void mouseEntered(MouseEvent evenement){
|
||||||
// System.out.println("mouseEntered");
|
|
||||||
}
|
}
|
||||||
public void mouseExited(MouseEvent evenement){
|
public void mouseExited(MouseEvent evenement){
|
||||||
// System.out.println("mouseExited");
|
|
||||||
}
|
}
|
||||||
public void mousePressed(MouseEvent evenement){
|
public void mousePressed(MouseEvent evenement){
|
||||||
// System.out.println("mousePressed");
|
|
||||||
}
|
}
|
||||||
public void mouseReleased(MouseEvent evenement){
|
public void mouseReleased(MouseEvent evenement){
|
||||||
// System.out.println("mouseReleased");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user