modif estetique et menuJeu
BIN
CASE/IMAGE/cinqD.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
CASE/IMAGE/deuxD.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
CASE/IMAGE/err.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
CASE/IMAGE/huitD.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
CASE/IMAGE/neufD.png
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
CASE/IMAGE/quatreD.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
CASE/IMAGE/sav.png
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
CASE/IMAGE/septD.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
CASE/IMAGE/sixD.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
CASE/IMAGE/troisD.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
CASE/IMAGE/unD.png
Normal file
After Width: | Height: | Size: 9.9 KiB |
BIN
CASE/IMAGE/zeroD.png
Normal file
After Width: | Height: | Size: 20 KiB |
@ -7,7 +7,9 @@ but: main_ex.class
|
||||
# Chapitre 2 : Variable
|
||||
OFILES= Case.class\
|
||||
plateau.class\
|
||||
observateurCase.class
|
||||
observateurCase.class\
|
||||
paintMenuJeu.class\
|
||||
observateurSAV.class
|
||||
|
||||
CFLAGS= -implicit:none
|
||||
|
||||
@ -15,12 +17,18 @@ CFLAGS= -implicit:none
|
||||
Case.class: Case.java
|
||||
javac $(CFLAGS) Case.java
|
||||
|
||||
plateau.class : plateau.java Case.class
|
||||
plateau.class : plateau.java
|
||||
javac $(CFLAGS) plateau.java
|
||||
|
||||
observateurCase.class : observateurCase.java Case.class
|
||||
observateurCase.class : observateurCase.java
|
||||
javac $(CFLAGS) observateurCase.java
|
||||
|
||||
paintMenuJeu.class: paintMenuJeu.java
|
||||
javac $(CFLAGS) paintMenuJeu.java
|
||||
|
||||
observateurSAV.class: observateurSAV.java
|
||||
javac $(CFLAGS) observateurSAV.java
|
||||
|
||||
# Chapitre 4 : Dependances
|
||||
|
||||
main_ex.class: $(OFILES) main_ex.java
|
||||
|
@ -10,13 +10,36 @@ public class main_ex{
|
||||
public static void main(String[] Args){
|
||||
// on initialise une fenettre
|
||||
JFrame fenetre = new JFrame("Démineur");
|
||||
int ligne=30;
|
||||
int collonne=80;
|
||||
int ligne=10;
|
||||
int collonne=20;
|
||||
int bombe=30;
|
||||
fenetre.setLocation(0,0);
|
||||
//on choisi une taille arbitraire
|
||||
fenetre.setSize(1500,800);
|
||||
|
||||
//nous utiliserons un gestionnaire GridLayout de dimensions choisi précédament
|
||||
GridLayout grille = new GridLayout(ligne,collonne);
|
||||
GridLayout grille = new GridLayout(ligne+1,collonne);
|
||||
paintMenuJeu[] tabScore= new paintMenuJeu[3];
|
||||
for(int i=0; i<collonne; i++){
|
||||
paintMenuJeu menu= new paintMenuJeu(0, bombe);
|
||||
menu.setPreferredSize(new Dimension(100,100));
|
||||
if(i==1){
|
||||
tabScore[0]=menu;
|
||||
menu.setChoix(1);
|
||||
}
|
||||
if(i==2){
|
||||
tabScore[1]=menu;
|
||||
menu.setChoix(2);
|
||||
}
|
||||
if(i==3){
|
||||
tabScore[2]=menu;
|
||||
menu.setChoix(3);
|
||||
}
|
||||
if(i==collonne-1){
|
||||
menu.setChoix(4);
|
||||
menu.addMouseListener(new observateurSAV(menu, fenetre));
|
||||
}
|
||||
fenetre.add(menu);
|
||||
}
|
||||
fenetre.setLayout(grille);
|
||||
// l'application ne se fermera que si on clique sur
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
@ -27,14 +50,16 @@ public class main_ex{
|
||||
for(int i=0; i<ligne; i++){
|
||||
for(int t=0; t<collonne; t++){
|
||||
tab[i][t]= new Case();
|
||||
tab[i][t].setPreferredSize(new Dimension(50,50));
|
||||
//nous ajoutons aussi a chaque case son observateur de case
|
||||
tab[i][t].addMouseListener(new observateurCase(i, t, tab));
|
||||
tab[i][t].addMouseListener(new observateurCase(i, t, tab, tabScore));
|
||||
fenetre.add(tab[i][t]);
|
||||
}
|
||||
}
|
||||
//nous disposons les bombe dans le jeu
|
||||
plateau.setAllBombe(300, ligne, collonne, tab);
|
||||
plateau.setAllBombe(bombe, ligne, collonne, tab);
|
||||
//maitenant que les bombe sont mise nous pouvons modifier le nombre de voisin des cases
|
||||
plateau.setAllVoisin(tab);
|
||||
fenetre.pack();
|
||||
}
|
||||
}
|
@ -9,10 +9,12 @@ public class observateurCase implements MouseListener{
|
||||
private int ligne, collonne;
|
||||
private Case[][] tableau;
|
||||
private plateau plat;
|
||||
public observateurCase(int ligne0, int collonne0, Case[][] tableau0){
|
||||
private paintMenuJeu[] tabScore;
|
||||
public observateurCase(int ligne0, int collonne0, Case[][] tableau0, paintMenuJeu[] tabScore0){
|
||||
this.ligne=ligne0;
|
||||
this.collonne=collonne0;
|
||||
this.tableau=tableau0;
|
||||
this.tabScore=tabScore0;
|
||||
}
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent evenement){
|
||||
@ -45,6 +47,16 @@ public class observateurCase implements MouseListener{
|
||||
this.tableau[this.ligne][this.collonne].suspition();
|
||||
this.tableau[this.ligne][this.collonne].repaint();
|
||||
//nous testons si le joeur a gagner/perdu
|
||||
if(this.tableau[this.ligne][this.collonne].getSuspition2()==true){
|
||||
for(int i=0; i<tabScore.length; i++){
|
||||
tabScore[i].setScore(tabScore[i].getScore()-1);
|
||||
}
|
||||
}
|
||||
if(this.tableau[this.ligne][this.collonne].getSuspition2()==false && this.tableau[this.ligne][this.collonne].getSuspition()==true){
|
||||
for(int i=0; i<tabScore.length; i++){
|
||||
tabScore[i].setScore(tabScore[i].getScore()+1);
|
||||
}
|
||||
}
|
||||
int resultat=plateau.etatDeVictoire(this.tableau);
|
||||
//si perdu
|
||||
if(resultat==-1){
|
||||
|
BIN
CASE/observateurSAV.class
Normal file
32
CASE/observateurSAV.java
Normal file
@ -0,0 +1,32 @@
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class observateurSAV implements MouseListener{
|
||||
private JFrame fenetre;
|
||||
private paintMenuJeu button;
|
||||
public observateurSAV(paintMenuJeu button0, JFrame fenetre0){
|
||||
this.button=button0;
|
||||
this.fenetre=fenetre0;
|
||||
}
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent evenement){
|
||||
this.fenetre.dispose();
|
||||
}
|
||||
@Override // un bouton cliqué
|
||||
public void mouseEntered(MouseEvent evenement){
|
||||
this.button.setSurvol(true);
|
||||
}
|
||||
@Override // debut du survol
|
||||
public void mouseExited(MouseEvent evenement){
|
||||
this.button.setSurvol(false);
|
||||
}
|
||||
@Override // fin du survol
|
||||
public void mousePressed(MouseEvent evenement){
|
||||
|
||||
}
|
||||
@Override // un bouton appuyé
|
||||
public void mouseReleased(MouseEvent evenement){
|
||||
|
||||
}
|
||||
}
|
BIN
CASE/paintMenuJeu.class
Normal file
122
CASE/paintMenuJeu.java
Normal file
@ -0,0 +1,122 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
public class paintMenuJeu extends JComponent{
|
||||
private int choix;
|
||||
private int score;
|
||||
private Image un, deux, trois, quatre, cinq, six, sept, huit, neuf, zero, err, sav;
|
||||
private boolean survol;
|
||||
public paintMenuJeu(int choix0, int score0){
|
||||
this.choix=choix0;
|
||||
this.score=score0;
|
||||
this.un=Toolkit.getDefaultToolkit().getImage("./IMAGE/unD.png");
|
||||
this.deux=Toolkit.getDefaultToolkit().getImage("./IMAGE/deuxD.png");
|
||||
this.trois=Toolkit.getDefaultToolkit().getImage("./IMAGE/troisD.png");
|
||||
this.quatre=Toolkit.getDefaultToolkit().getImage("./IMAGE/quatreD.png");
|
||||
this.cinq=Toolkit.getDefaultToolkit().getImage("./IMAGE/cinqD.png");
|
||||
this.six=Toolkit.getDefaultToolkit().getImage("./IMAGE/sixD.png");
|
||||
this.sept=Toolkit.getDefaultToolkit().getImage("./IMAGE/septD.png");
|
||||
this.huit=Toolkit.getDefaultToolkit().getImage("./IMAGE/huitD.png");
|
||||
this.neuf=Toolkit.getDefaultToolkit().getImage("./IMAGE/neufD.png");
|
||||
this.zero=Toolkit.getDefaultToolkit().getImage("./IMAGE/zeroD.png");
|
||||
this.err=Toolkit.getDefaultToolkit().getImage("./IMAGE/err.png");
|
||||
this.sav=Toolkit.getDefaultToolkit().getImage("./IMAGE/sav.png");
|
||||
this.survol=false;
|
||||
}
|
||||
public void setChoix(int choix0){
|
||||
this.choix=choix0;
|
||||
this.repaint();
|
||||
}
|
||||
public void setScore(int score0){
|
||||
this.score=score0;
|
||||
this.repaint();
|
||||
}
|
||||
public int getScore(){
|
||||
return this.score;
|
||||
}
|
||||
public void setSurvol(boolean survol0){
|
||||
this.survol=survol0;
|
||||
this.repaint();
|
||||
}
|
||||
@Override
|
||||
protected void paintComponent(Graphics pinceau) {
|
||||
// obligatoire : on crée un nouveau pinceau pour pouvoir le modifier plus tard
|
||||
Graphics secondPinceau = pinceau.create();
|
||||
// obligatoire : si le composant n'est pas censé être transparent
|
||||
if (this.isOpaque()) {
|
||||
// obligatoire : on repeint toute la surface avec la couleur de fond
|
||||
secondPinceau.setColor(this.getBackground());
|
||||
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||
}
|
||||
//On paint ce que l'on veut maintenant
|
||||
secondPinceau.setColor(new Color(0,0,0));
|
||||
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||
if(this.choix==1){
|
||||
int nombre=this.score/100;
|
||||
this.paintNombre(secondPinceau, nombre);
|
||||
}
|
||||
if(this.choix==2){
|
||||
int nombre=this.score;
|
||||
if(nombre>=100){
|
||||
nombre=this.score-100*(this.score/100);
|
||||
}
|
||||
nombre=nombre/10;
|
||||
this.paintNombre(secondPinceau, nombre);
|
||||
}
|
||||
if(this.choix==3){
|
||||
int nombre=this.score;
|
||||
if(nombre>=100){
|
||||
nombre=this.score-100*(this.score/100);
|
||||
}
|
||||
if(nombre>=10){
|
||||
nombre=this.score-10*(this.score/10);
|
||||
}
|
||||
this.paintNombre(secondPinceau, nombre);
|
||||
}
|
||||
if(this.choix==4){
|
||||
if(this.survol==true){
|
||||
secondPinceau.setColor(new Color(0,255,0));
|
||||
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||
}
|
||||
secondPinceau.drawImage(this.sav, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this);
|
||||
}
|
||||
}
|
||||
private void paintNombre(Graphics secondPinceau, int nombre){
|
||||
if(this.score>=0){
|
||||
if(nombre==1){
|
||||
secondPinceau.drawImage(this.un, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this);
|
||||
}
|
||||
if(nombre==2){
|
||||
secondPinceau.drawImage(this.deux, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this);
|
||||
}
|
||||
if(nombre==3){
|
||||
secondPinceau.drawImage(this.trois, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this);
|
||||
}
|
||||
if(nombre==4){
|
||||
secondPinceau.drawImage(this.quatre, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this);
|
||||
}
|
||||
if(nombre==5){
|
||||
secondPinceau.drawImage(this.cinq, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this);
|
||||
}
|
||||
if(nombre==6){
|
||||
secondPinceau.drawImage(this.six, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this);
|
||||
}
|
||||
if(nombre==7){
|
||||
secondPinceau.drawImage(this.sept, this.getWidth()/6, this.getHeight()/20*5, this.getWidth()/6*4, this.getHeight()/6*4 ,this);
|
||||
}
|
||||
if(nombre==8){
|
||||
secondPinceau.drawImage(this.huit, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this);
|
||||
}
|
||||
if(nombre==9){
|
||||
secondPinceau.drawImage(this.neuf, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this);
|
||||
}
|
||||
if(nombre==0){
|
||||
secondPinceau.drawImage(this.zero, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this);
|
||||
}
|
||||
}else{
|
||||
secondPinceau.drawImage(this.err, this.getWidth()/20*5, this.getHeight()/20*5, this.getWidth()/6*4, this.getHeight()/6*4 ,this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|