entourage presque opérationel
This commit is contained in:
parent
d4f8e33c51
commit
cbddb740c6
17
Case.java
17
Case.java
@ -3,16 +3,19 @@ import java.awt.*;
|
|||||||
|
|
||||||
public class Case extends JComponent {
|
public class Case extends JComponent {
|
||||||
private JPanel panel = new JPanel();
|
private JPanel panel = new JPanel();
|
||||||
private int entourage=0;
|
private int entourage;
|
||||||
private boolean visible=false;
|
private boolean visible;
|
||||||
private boolean minee=false;
|
private boolean minee;
|
||||||
|
|
||||||
public Case(Dimension caseSize, boolean visible, boolean minee, int entourage) {
|
public Case(Dimension caseSize, boolean visible, boolean minee, int entourage) {
|
||||||
super();
|
super();
|
||||||
this.panel.setSize(caseSize);
|
|
||||||
this.entourage=entourage;
|
this.entourage=entourage;
|
||||||
this.visible=visible;
|
this.visible=visible;
|
||||||
this.minee=minee;
|
this.minee=minee;
|
||||||
|
this.panel.setSize(caseSize);
|
||||||
|
|
||||||
|
GridLayout unique = new GridLayout(1,1);
|
||||||
|
this.panel.setLayout(unique);
|
||||||
|
|
||||||
if (this.visible == false) {
|
if (this.visible == false) {
|
||||||
Color gray2 = new Color(70, 70, 70);
|
Color gray2 = new Color(70, 70, 70);
|
||||||
@ -25,16 +28,12 @@ public class Case extends JComponent {
|
|||||||
this.panel.setBackground(rose);
|
this.panel.setBackground(rose);
|
||||||
} else if (this.entourage>0){
|
} else if (this.entourage>0){
|
||||||
System.out.println(""+ this.entourage);
|
System.out.println(""+ this.entourage);
|
||||||
|
this.panel.add(new Chiffre(entourage,caseSize));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void paintComponent(Graphics pinceau) {
|
|
||||||
System.out.println("coucou");
|
|
||||||
}
|
|
||||||
|
|
||||||
public JPanel getCase() {
|
public JPanel getCase() {
|
||||||
return this.panel;
|
return this.panel;
|
||||||
}
|
}
|
||||||
|
22
Chiffre.java
Normal file
22
Chiffre.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import javax.swing.JComponent;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class Chiffre extends JComponent {
|
||||||
|
private int entourage;
|
||||||
|
private Dimension caseSize;
|
||||||
|
public Chiffre(int entourage, Dimension caseSize) {
|
||||||
|
super();
|
||||||
|
this.entourage = entourage;
|
||||||
|
this.caseSize=caseSize;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void paintComponent(Graphics pinceau) {
|
||||||
|
Graphics chiffre = pinceau.create();
|
||||||
|
Font font = new Font("Arial", Font.BOLD, 40);
|
||||||
|
chiffre.setFont(font);
|
||||||
|
Color jaune = new Color(236, 214, 0);
|
||||||
|
chiffre.setColor(jaune);
|
||||||
|
chiffre.drawString(Integer.toString(this.entourage),caseSize.width/3,caseSize.height*8/10);
|
||||||
|
System.out.println(""+caseSize);
|
||||||
|
}
|
||||||
|
}
|
@ -5,13 +5,15 @@ import java.awt.*;
|
|||||||
// Création d'un Jcomponent Etoile, qui sert pour le marquage des mines
|
// Création d'un Jcomponent Etoile, qui sert pour le marquage des mines
|
||||||
public class Etoile extends JComponent {
|
public class Etoile extends JComponent {
|
||||||
private Image etoileImage;
|
private Image etoileImage;
|
||||||
public Etoile() {
|
private Dimension caseSize;
|
||||||
|
public Etoile(Dimension caseSize) {
|
||||||
super();
|
super();
|
||||||
|
this.caseSize=caseSize;
|
||||||
this.etoileImage = Toolkit.getDefaultToolkit().getImage("etoile.png");
|
this.etoileImage = Toolkit.getDefaultToolkit().getImage("etoile.png");
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void paintComponent(Graphics pinceau) {
|
protected void paintComponent(Graphics pinceau) {
|
||||||
Graphics etoile = pinceau.create();
|
Graphics etoile = pinceau.create();
|
||||||
etoile.drawImage(this.etoileImage,5,10,90,80,this);
|
etoile.drawImage(this.etoileImage,this.caseSize.width*1/20,this.caseSize.height*1/10,this.caseSize.width*9/10,this.caseSize.height*8/10,this);
|
||||||
}
|
}
|
||||||
}
|
}
|
12
Grille.java
12
Grille.java
@ -6,7 +6,7 @@ public class Grille extends JComponent {
|
|||||||
private Dimension grilleSize=new Dimension(0,0);
|
private Dimension grilleSize=new Dimension(0,0);
|
||||||
private JPanel grille= new JPanel();
|
private JPanel grille= new JPanel();
|
||||||
|
|
||||||
// On créer La grille de jeu
|
// On crée La grille de jeu
|
||||||
public Grille(int lignes, int colonnes, int mines){
|
public Grille(int lignes, int colonnes, int mines){
|
||||||
|
|
||||||
// Découpage de l'espace en fonction des paramètres pour la mise en place de la grille
|
// Découpage de l'espace en fonction des paramètres pour la mise en place de la grille
|
||||||
@ -90,12 +90,16 @@ public class Grille extends JComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Affichage des cases
|
AffichePlateau(lignes*colonnes, caseSize, entourage, visible, minee);
|
||||||
for (int i=0;i<lignes*colonnes;i++){
|
}
|
||||||
|
|
||||||
|
// Méthode pour afficher l'état des cases
|
||||||
|
protected void AffichePlateau(int taille, Dimension caseSize, int[] entourage, boolean[] visible, boolean[] minee){
|
||||||
|
for (int i=0;i<taille;i++){
|
||||||
Case panel = new Case(caseSize,visible[i],minee[i],entourage[i]);
|
Case panel = new Case(caseSize,visible[i],minee[i],entourage[i]);
|
||||||
this.grille.add(panel.getCase());
|
this.grille.add(panel.getCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Méthode pour obtenir la taille de la grille de jeu
|
// Méthode pour obtenir la taille de la grille de jeu
|
||||||
public Dimension getGrilleSize() {
|
public Dimension getGrilleSize() {
|
||||||
|
Loading…
Reference in New Issue
Block a user