import java.awt.*; import javax.swing.*; import java.awt.event.*; import javax.imageio.ImageIO; import java.io.IOException; import java.io.File; import java.awt.Graphics; import java.awt.Image; public class Panneau extends JPanel { private Personnage monPersonnage; private Bloc tabBloc[][]; private Marteau lemarteau; public Panneau() { tabBloc= new Bloc[23][32]; // Blocs non cassables premier affichage for(int j=0;j<23;j++) { tabBloc[21][j]=new Bloc (1); tabBloc[22][j]=new Bloc (1); } tabBloc[19][10]=new Bloc (1); tabBloc[14][13]=new Bloc (1); tabBloc[15][15]=new Bloc (1); tabBloc[16][15]=new Bloc (1); tabBloc[17][16]=new Bloc (1); tabBloc[20][18]=new Bloc (1); tabBloc[18][19]=new Bloc (1); tabBloc[19][19]=new Bloc (1); tabBloc[20][19]=new Bloc (1); tabBloc[17][20]=new Bloc (1); tabBloc[18][20]=new Bloc (1); tabBloc[19][20]=new Bloc (1); tabBloc[20][20]=new Bloc (1); tabBloc[17][21]=new Bloc (1); tabBloc[18][21]=new Bloc (1); tabBloc[19][21]=new Bloc (1); tabBloc[20][21]=new Bloc (1); tabBloc[17][23]=new Bloc (1); tabBloc[18][23]=new Bloc (1); tabBloc[19][23]=new Bloc (1); tabBloc[20][23]=new Bloc (1); tabBloc[21][23]=new Bloc (1); tabBloc[22][23]=new Bloc (1); tabBloc[16][24]=new Bloc (1); tabBloc[17][24]=new Bloc (1); tabBloc[18][24]=new Bloc (1); tabBloc[19][24]=new Bloc (1); tabBloc[20][24]=new Bloc (1); tabBloc[21][24]=new Bloc (1); tabBloc[22][24]=new Bloc (1); tabBloc[15][26]=new Bloc (1); tabBloc[16][26]=new Bloc (1); tabBloc[17][26]=new Bloc (1); tabBloc[18][26]=new Bloc (1); tabBloc[19][26]=new Bloc (1); tabBloc[20][26]=new Bloc (1); tabBloc[21][26]=new Bloc (1); tabBloc[22][26]=new Bloc (1); tabBloc[16][28]=new Bloc (1); tabBloc[17][28]=new Bloc (1); tabBloc[18][28]=new Bloc (1); tabBloc[19][28]=new Bloc (1); tabBloc[20][28]=new Bloc (1); tabBloc[21][28]=new Bloc (1); tabBloc[22][28]=new Bloc (1); tabBloc[17][29]=new Bloc (1); tabBloc[18][29]=new Bloc (1); tabBloc[19][29]=new Bloc (1); tabBloc[20][29]=new Bloc (1); tabBloc[21][29]=new Bloc (1); tabBloc[22][29]=new Bloc (1); } public void paintComponent(Graphics g) { super.paintComponent(g); g.drawImage(Toolkit.getDefaultToolkit().getImage("lave.gif"),0,0,800,600,this); // Fond d'écran g.drawImage(Toolkit.getDefaultToolkit().getImage("Marteau.jpg"),150,525,25,25,this); for(int i=0;i<22;i++) { for(int j=0;j<31;j++) { if (getBloc(i,j) == 1) { g.drawImage(Toolkit.getDefaultToolkit().getImage("bloc_lave.jpg"),25*j,25*i+25,25,25,this); } else { if (tabBloc[i][j]==2) { g.drawImage(Toolkit.getDefaultToolkit().getImage("bloc_cassable_lave.jpg"),25*j,25*i+25,25,25,this); } else { if (tabBloc[i][j]==3) { g.drawImage(Toolkit.getDefaultToolkit().getImage("diamant.jpg"),25*j,25*i+30,25,25,this); } else { if(tabBloc[i][j]==4) { g.drawImage(Toolkit.getDefaultToolkit().getImage("marteau.jpg"),25*j,25*i+30,25,25,this); } } } } } } } }