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

View File

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

View File

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

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB