Skip to content
Snippets Groups Projects
Commit 4767ee5b authored by bosskkev's avatar bosskkev
Browse files

Nettoyage du code. Bug majeur: impossible d'afficher deux images en même temps

parent fb10721a
No related branches found
No related tags found
No related merge requests found
Pipeline #22690 failed
......@@ -20,20 +20,20 @@ public class Grid extends JFrame {
// mainPanel.setBounds(850,500,122,124);
this.setTitle(title);
// this.setContentPane(mainPanel);
this.setSize(width, height);
this.setMinimumSize(new Dimension(width, height));
// this.setContentPane(mainPanel);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLocationRelativeTo(null);
this.setResizable(false);
this.setVisible(true);
JPanel playerPanel = new JPanel();
this.getContentPane().add(playerPanel, BorderLayout.CENTER);
kernel.start();
kernel.setKeysListeners(playerPanel);
kernel.setKeysListeners((JPanel) getContentPane());
this.pack();
this.revalidate();
revalidate();
}
public void draw(ImageComponent ic) throws IOException {
getContentPane().add(ic);
......
......@@ -17,8 +17,8 @@ public class ImageComponent extends JComponent {
this.position = position;
//this.setBorder(BorderFactory.createLineBorder(Color.black));
this.setSize(width, height);
setVisible(true);
setLayout(null);
this.setVisible(true);
this.setLayout(null);
//repaint();
}
......@@ -33,9 +33,8 @@ public class ImageComponent extends JComponent {
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.BLUE);
g.drawImage(image, position.getX(), position.getY(), width,height ,this);
g.drawImage(image, position.getX(), position.getY(), this.width, this.height, this);
//setOpaque(false);
}
}
\ No newline at end of file
......@@ -31,7 +31,7 @@ public class Kernel {
for (PongObject pongObject: PongApp.components) {
//Coordinates2D speed = new Coordinates2D(random.nextInt(2) - 1, random.nextInt(2) - 1);
Coordinates2D speed = new Coordinates2D(0, 0);
Coordinates2D speed = new Coordinates2D(0, 1);
pongObjectEntityHashMap.put(pongObject, new Movable(1, pongObject.getPosition(), speed, new Coordinates2D(0, 0), 1));
grid.draw(new ImageComponent(pongObject.getImage(), pongObject.getPosition(), pongObject.getWidth(), pongObject.getHeight()));
}
......
......@@ -59,7 +59,7 @@ public class Grid extends JFrame {
* @throws IOException
*/
public void draw(Coordinates2D position, Image image, int width, int height) throws IOException {
getContentPane().add(new CircleComponent(100));
//getContentPane().add(new CircleComponent(100));
//getContentPane().add(new ImageComponent(image, position, width, height));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment