joueur posé (à redimensionner avec bufferedimage) et icone jeu

This commit is contained in:
diane 2023-04-23 18:19:43 +02:00
parent bfc7fb6379
commit 3853b91635
5 changed files with 20 additions and 14 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

View File

@ -1,6 +1,8 @@
package graphique;
import java.awt.*;
import java.awt.image.BufferedImage;
import javax.swing.*;
public class JPanelDessin extends JPanel {
@ -30,10 +32,12 @@ public class JPanelDessin extends JPanel {
int x, y;
width = this.getWidth();
height = this.getHeight();
System.out.println("width = "+width);
System.out.println("height = "+height);
x=0;
y=0;
while (y<height) {
g.setColor(new Color(235, 235, 235));
g.setColor(new Color(1, 255, 0));
g.drawLine(0, y, width, y);
y= y + height/11;
}
@ -43,6 +47,7 @@ public class JPanelDessin extends JPanel {
x= x + width/11;
}
// // Affiche un cercle noir au centre
// g.setColor(Color.black);
// g.drawOval( this.getWidth() / 2, this.getHeight() / 2, 10, 10);

View File

@ -53,6 +53,7 @@ public class JPanelImage extends JPanel {
}
}
}
//import java.awt.*;

View File

@ -52,7 +52,7 @@ public class MaJFrame extends JFrame {
private JLabel lblZombicide;
private JPanel panelInfo;
private JButton btnDeplacer;
private JButton btnTuer;
private JButton btnAttaquer;
private JSpinner deplacementX;
private JSpinner deplacementY;
private JLabel lblDepX;
@ -94,6 +94,7 @@ public class MaJFrame extends JFrame {
* @throws IOException
*/
public MaJFrame() throws IOException {
setIconImage(Toolkit.getDefaultToolkit().getImage(MaJFrame.class.getResource("/images/zombie.png")));
// création et variable contentPane
setTitle("Zombicide");
setBackground(new Color(128, 0, 0));
@ -159,11 +160,10 @@ public class MaJFrame extends JFrame {
//ajout joueur
lblJoueur = new JLabel();//"map1.jpg"
lblJoueur.setText("J");
lblJoueur = new JLabel();
lblJoueur.setForeground(new Color(255, 128, 0));
joueurIcon = new ImageIcon("joueur.png");
lblJoueur.setIcon(joueurIcon);
//joueurIcon = new ImageIcon("joueur.png");
lblJoueur.setIcon(new ImageIcon(MaJFrame.class.getResource("/images/joueur.png")));
GridBagConstraints gbc_joueur = new GridBagConstraints();
gbc_joueur.fill = GridBagConstraints.CENTER;
gbc_joueur.gridx = 2;
@ -337,17 +337,17 @@ public class MaJFrame extends JFrame {
gbc_deplacementY.gridy = 8;
panelInfo.add(deplacementY, gbc_deplacementY);
//création boutonTuer
btnTuer = new JButton("Tuer");
btnTuer.addActionListener(new ActionListener() {
//création boutonAttaquer
btnAttaquer = new JButton("Attaquer");
btnAttaquer.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
GridBagConstraints gbc_btnTuer = new GridBagConstraints();
gbc_btnTuer.fill = GridBagConstraints.BOTH;
gbc_btnTuer.gridx = 0;
gbc_btnTuer.gridy = 10;
panelInfo.add(btnTuer, gbc_btnTuer);
GridBagConstraints gbc_btnAttaquer = new GridBagConstraints();
gbc_btnAttaquer.fill = GridBagConstraints.BOTH;
gbc_btnAttaquer.gridx = 0;
gbc_btnAttaquer.gridy = 10;
panelInfo.add(btnAttaquer, gbc_btnAttaquer);
}

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB