Commit dd431a29 authored by Julien VACHER's avatar Julien VACHER
Browse files

julien : final version 2.0

parent 1ff1fab7
......@@ -40,61 +40,54 @@ public class MenuJeu extends JFrame {
public MenuJeu(String titre, NavyFleet flotte) {
super(titre);
creerinterfacejeu(flotte);
this.setPreferredSize(new Dimension(1000, 800));
this.pack();
this.setResizable(false);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setContentPane(fenetrejeu);
File f = new File("img/fond.jpg");
img = new ImagePanel();
img.chargerImage(f);
fenetrejeu = new JPanel(new BorderLayout());
}
fenetrejeu.setBackground(new Color(0,0,0,0));
lesplateaux = new JPanel(new GridLayout(1,2));
lesplateaux.setBackground(new Color(0,0,0,0));
plateau = InitialisePlateauJoueur(flotte);
plateauadverse = InitialisePlateauAdverse();
public JPanel InitialisePlateauAdverse() {
//création plateau :
quadrillage = new ArrayList<JPanelCoords>();
JPanel plateau = new JPanel(new GridLayout(11, 11, 2, 2));
plateau.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
String[] tab = new String[]{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J"};
for (int i = 0; i < 11; i++) {
for (int j = 0; j < 11; j++) {
if (i == 0 && j != 0) {
String test = tab[j - 1];
lacase = new JLabel(test, lacase.CENTER);
lacase.setBorder(BorderFactory.createLineBorder(Color.BLACK));
plateau.add(lacase);
joueur = new JPanel(new BorderLayout());
joueur.setBackground(new Color(0,0,0,0));
toi = new JLabel("Ma Flotte",JLabel.CENTER);
toi.setFont(new Font("Serif", Font.BOLD, 20));
toi.setForeground(new Color(255,0,0));
adversaire = new JPanel(new BorderLayout());
adversaire.setBackground(new Color(0,0,0,0));
other = new JLabel("L'ennemi",JLabel.CENTER);
other.setFont(new Font("Serif", Font.BOLD, 20));
other.setForeground(new Color(255,0,0));
} else if (j==0 && i!=0) {
int test = i;
lacase = new JLabel(String.valueOf(test), lacase.CENTER);
lacase.setBorder(BorderFactory.createLineBorder(Color.BLACK));
plateau.add(lacase);
joueur.add(toi,BorderLayout.SOUTH);
joueur.add(plateau,BorderLayout.CENTER);
adversaire.add(other,BorderLayout.SOUTH);
adversaire.add(plateauadverse,BorderLayout.CENTER);
lesplateaux.add(joueur);
lesplateaux.add(adversaire);
fenetrejeu.add(lesplateaux, BorderLayout.CENTER);
fenetrejeu.setPreferredSize(new Dimension(900,690));
img.add(fenetrejeu);
} else if (i == 0 && j==0) {
JPanel lacell = new JPanel();
lacell.setBorder(BorderFactory.createLineBorder(Color.BLACK));
plateau.add(lacell);
} else {
JPanelCoords cell = new JPanelCoords(j,i);
cell.setBackground(new Color(233,233,233));
cell.setBorder(BorderFactory.createLineBorder(Color.BLACK));
plateau.add(cell);
quadrillage.add(cell);
}
}
}
return plateau;
this.setPreferredSize(new Dimension(1000, 800));
this.pack();
this.setResizable(false);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setContentPane(img);
}
public JPanel InitialisePlateauAdverse2(String coord) {
//création plateau :
JPanelCoords lacaserouge = new JPanelCoords(coord);
public JPanel InitialisePlateauAdverse() {
//création plateau :
quadrillage = new ArrayList<JPanelCoords>();
JPanel plateau = new JPanel(new GridLayout(11, 11, 2, 2));
plateau.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
......@@ -133,7 +126,7 @@ public class MenuJeu extends JFrame {
}
//public actualise
public JPanel InitialisePlateauJoueur(NavyFleet flotte) {
//création plateau :
quadrillage2 = new ArrayList<JPanelCoords>();
......@@ -242,97 +235,6 @@ public class MenuJeu extends JFrame {
public JPanel creerinterfacejeu(NavyFleet flotte){
//interface jeu
File f = new File("img/fond.jpg");
img = new ImagePanel();
img.chargerImage(f);
fenetrejeu = new JPanel(new BorderLayout());
fenetrejeu.setBackground(new Color(0,0,0,0));
lesplateaux = new JPanel(new GridLayout(1,2));
lesplateaux.setBackground(new Color(0,0,0,0));
plateau = InitialisePlateauJoueur(flotte);
plateauadverse = InitialisePlateauAdverse();
joueur = new JPanel(new BorderLayout());
joueur.setBackground(new Color(0,0,0,0));
toi = new JLabel("Ma Flotte",JLabel.CENTER);
toi.setFont(new Font("Serif", Font.BOLD, 20));
toi.setForeground(new Color(255,0,0));
viejoueur = new JPanel(new GridLayout(5,1));
viejoueur.setBackground(new Color(0,0,0,0));
vieadversaire = new JPanel(new GridLayout(5,1));
vieadversaire.setBackground(new Color(0,0,0,0));
if(etat){
GetStringBateauFrance();
GetIntBateauFrance();
}else {
GetStringBateauBelgique();
GetIntBateauBelgique();
}
bouttonmaflotte = new ArrayList<JButton>();
for(int i=0;i<tabstring.length;i++){
thecase = new JPanel(new BorderLayout());
thecase.setBackground(new Color(0,0,0,0));
JButton txt = new JButton(tabstring[i]);
bouttonmaflotte.add(txt);
thecase.add(txt,BorderLayout.WEST);
JLabel coeur = new JLabel(String.valueOf(tabint[i]));
thecase.add(coeur,BorderLayout.EAST);
viejoueur.add(thecase);
}
bouttonflotteadverse = new ArrayList<JButton>();
for(int j=0;j<tabstring.length;j++){
thecaseadverse = new JPanel(new BorderLayout());
thecaseadverse.setBackground(new Color(0,0,0,0));
JButton txtadverse = new JButton(tabstring[j]);
//txtadverse.setBackground(new Color(0,0,0,0));
bouttonflotteadverse.add(txtadverse);
thecaseadverse.add(txtadverse,BorderLayout.WEST);
JLabel coeuradverse = new JLabel(String.valueOf(tabint[j]));
thecaseadverse.add(coeuradverse,BorderLayout.EAST);
vieadversaire.add(thecaseadverse);
}
adversaire = new JPanel(new BorderLayout());
adversaire.setBackground(new Color(0,0,0,0));
other = new JLabel("L'ennemi",JLabel.CENTER);
other.setFont(new Font("Serif", Font.BOLD, 20));
other.setForeground(new Color(255,0,0));
joueur.add(toi,BorderLayout.SOUTH);
joueur.add(plateau,BorderLayout.CENTER);
adversaire.add(other,BorderLayout.SOUTH);
adversaire.add(plateauadverse,BorderLayout.CENTER);
lesplateaux.add(joueur);
lesplateaux.add(adversaire);
fenetrejeu.add(lesplateaux, BorderLayout.CENTER);
fenetrejeu.setPreferredSize(new Dimension(900,690));
img.add(fenetrejeu);
return img;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment