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
|
public class Phasedejeu extends JFrame{
private JPanelDessin2 jPanel5 = new JPanelDessin2(this);
private Dimension dim = jPanel5.getSize() ;
private int larg = dim.width ;
private int haut = dim.height;
public int getLarg(){
return larg;
}
public void setLarg(int x){
larg=x;
}
public int getHaut(){
return haut;
}
public void setHaut(int y){
haut=y;
}
}
class JPanelDessin2 extends JPanel {
private PhaseDeJeu jeu;
private int largeur;
private int hauteur;
public JPanelDessin2(PhaseDeJeu paramJeu){
this.jeu=paramJeu;
this.largeur = jeu.getLarg();
this.hauteur = jeu.getHaut();
}
public void paintComponent (Graphics g) {
super.paintComponent(g);
this.setBackground(Color.white);
int x=largeur*200; int y=hauteur*200;
g.drawImage(texture,0,0,1350,758,this);
g.drawImage(tete2,200,50,x,y, this);
g.drawImage(fourmiliere,50,100,100,100,this);
}
} |
Partager