1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
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];
for(int i=0;i<23;i++) {
for (int j=0;j<32;j++) {
tabBloc[i][j]=new Bloc(0);
}
}
// 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);
System.out.println(""+tabBloc[0][0].getType());
for(int i=0;i<22;i++)
{
for(int j=0;j<31;j++)
{
if (tabBloc[i][j].getType() == 1)
{
g.drawImage(Toolkit.getDefaultToolkit().getImage("bloc_lave.jpg"),25*j,25*i+25,25,25,this);
}
else
{
if (tabBloc[i][j].getType()==2)
{
g.drawImage(Toolkit.getDefaultToolkit().getImage("bloc_cassable_lave.jpg"),25*j,25*i+25,25,25,this);
}
else
{
if (tabBloc[i][j].getType()==3)
{
g.drawImage(Toolkit.getDefaultToolkit().getImage("diamant.jpg"),25*j,25*i+30,25,25,this);
}
else
{
if(tabBloc[i][j].getType()==4)
{
g.drawImage(Toolkit.getDefaultToolkit().getImage("marteau.jpg"),25*j,25*i+30,25,25,this);
}
}
}
}
}
}
}
} |