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
| import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
public class Test01_Panneau extends JPanel {
public void paintComponent(Graphics g){
try {
//fond
Image img = ImageIO.read(new File("img/fond.jpg"));
g.drawImage(img, 0, 0, this.getWidth(), this.getHeight(), this);
} catch (IOException e) {
e.printStackTrace();
}
//texte
Font font = new Font("Times New Roman", Font.BOLD, 30);
g.setFont(font);
g.setColor(Color.BLACK);
g.drawString("-->Tiens !Adriens!Que regardes-tu gros pervers?<--",40 , 50);
//Cible 1
g.setColor(Color.blue);
g.fillOval(posX, posY, 50, 50);
//Cible 2 bonnus
Image img_Bonus;
try {
img_Bonus = ImageIO.read(new File("img/bonus.jpg"));
g.drawImage(img_Bonus, posXb, posYb, this);
} catch (IOException e) {
e.printStackTrace();
}
//Tir
g.setColor(Color.GREEN);
g.fillRect(posX1, posY1 ,10,65);
//Origine du tir
Image img_tireur;
try {
img_tireur = ImageIO.read(new File("img/tireur.jpg"));
g.drawImage(img_tireur, 500, 500, this);
} catch (IOException e) {
e.printStackTrace();
}
}
//Information necessaire a l'animation
//Animation cible 1)
private int posX = -50;
private int posY = 75;
public int getPosX() {
return posX;
}
public void setPosX(int posX) {
this.posX = posX;
}
public int getPosY() {
return posY;
}
public void setPosY(int posY) {
this.posY = posY;
}
//Animation cible 2-cible BONUS-
private int posXb=100;//b pour bonnus
private int posYb=-30;
public int getPosXb(){
return posXb;
}
public void setPosXb(int posXb){
this.posXb=posXb;
}
public int getPosYb(){
return posYb;
}
public void setPosYb(int posYb){
this.posYb=posYb;
}
//animation tir
private int posX1 = 530;//idealemt:getWidth()/2 +25;
private int posY1 = 500;//idealemt:getHeight()-250;
public int getPosX1() {
return posX1;
}
public void setPosX1( int posX1) {
this.posX1 = posX1;
}
public int getPosY1() {
return posY1;
}
public void setPosY1(int posY1) {
this.posY1 = posY1;
}
} |
Partager