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
|
public class MapLevel1 extends JPanel{
private ImageIcon blocGlace;
private ImageIcon poisson;
private ImageIcon bonus;
private ImageIcon mechant;
private TableauMapLevel1 tab;
private PlayerPengos pingouin;
MapLevel1(TableauMapLevel1 tab, PlayerPengos pingouin) {
this.setBounds(0,0,650,537);
this.tab = tab;
this.pingouin = pingouin;
blocGlace = new ImageIcon("./img/block1.PNG");
poisson = new ImageIcon("./img/herringicon.PNG");
vie = new ImageIcon("./img/vie.GIF");
perduVie = new ImageIcon("./img/perdu_vie.GIF");
panneauScore = new ImageIcon("./img/panneauScore.GIF");
bonus = new ImageIcon("./img/pengosSuperMan/SM_LEFT/pengosSM1.GIF");
mechant = new ImageIcon("./img/walker2.PNG");
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
setBackground(new Color(150,200,255));
int x = 0;
int y = 0;
/** partie map**/
for(int i =0; i<tab.getPlateau().length; i++){
for(int j=0; j<tab.getPlateau().length; j++) {
if(tab.getPlateauIJ(i,j) == 0) {
g.drawImage(blocGlace.getImage(),x,y,null);
x += 24;
}
else if(tab.getPlateauIJ(i,j) == 1) {
y += 7;
x+= 2;
g.drawImage(poisson.getImage(),x,y,null);
x += 22;
y -= 7;
}
else if(tab.getPlateauIJ(i,j) == 2) {
g.drawImage(bonus.getImage(),x,y,null);
x += 24;
}
else if(tab.getPlateauIJ(i,j) == 3) {
x += 24;
}
else if(tab.getPlateauIJ(i,j) == 4) {
//g.drawImage(mechant.getImage(),x,y,null);
x += 24;
}
else {
x += 24;
}
}
y +=24;
x = 0;
}
}
} |
Partager