This commit is contained in:
Simoes Lukas
2025-03-27 13:35:54 +01:00
parent 376861b608
commit fe693705bf
90 changed files with 1188 additions and 24 deletions

Binary file not shown.

View File

@@ -0,0 +1,40 @@
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ClicCase implements MouseListener {
private JPanel[][] cases;
private int[][] grille;
private int caseX;
private int caseY;
public ClicCase(JPanel[][] cases, int[][] grille, int caseX, int caseY) {
this.cases = cases;
this.grille = grille;
this.caseX = caseX;
this.caseY = caseY;
}
public void mouseClicked(MouseEvent evenement) {
this.cases[this.caseX][this.caseY].setLayout(new GridLayout());
this.cases[this.caseX][this.caseY].add(new Image());
} // un bouton cliqué
public void mouseEntered(MouseEvent evenement) {
} // debut du survol
public void mouseExited(MouseEvent evenement) {
} // fin du survol
public void mousePressed(MouseEvent evenement) {
} // un bouton appuyé
public void mouseReleased(MouseEvent evenement) {
} // un bouton relâché
}

Binary file not shown.

View File

@@ -0,0 +1,29 @@
import java.awt.*;
import javax.swing.*;
import java.util.Arrays;
public class Fenetre extends JFrame {
public Fenetre() {
this.setSize(500,500);
this.setLocation(100,100);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new GridLayout(10, 10));
JPanel[][] cases = new JPanel[10][10];
int[][] grille = new int[10][10];
for (int i = 0; i != 10; i++) {
for (int j = 0; j != 10; j++) {
cases[i][j] = new JPanel();
cases[i][j].setBackground(new Color(37, 150, 190));
cases[i][j].setBorder(BorderFactory.createLineBorder(Color.WHITE));
cases[i][j].addMouseListener(new ClicCase(cases, grille, i, j));
this.add(cases[i][j]);
grille[i][j] = 0;
}
}
}
}

Binary file not shown.

View File

@@ -0,0 +1,35 @@
import java.awt.*;
public class GestionGrille {
private int[][] grille;
private Point[] coordsTrainee;
private Point coordJoueur;
public GestionGrille(Point[] coordsTrainee, Point coordJoueur) {
for (int i = 0; i != 10; i++) {
for (int j = 0; j != 10; j++) {
this.grille[i][j] = 0;
}
}
this.coordsTrainee = coordsTrainee;
this.coordJoueur = coordJoueur;
}
public boolean deplacementPossible(Point destination) {
if (this.coordJoueur.getX() == destination.getX()
&& this.coordJoueur.getY() == destination.getY()-1) {
return true;
}
else if (this.coordJoueur.getX() == destination.getX()
&& this.coordJoueur.getY() == destination.getY()+1) {
return true;
}
else if (this.coordJoueur.getX() == destination.getX()+1
&& this.coordJoueur.getY() == destination.getY()) {
return true;
}
return false;
}
}

View File

@@ -0,0 +1,13 @@
import java.awt.*;
import javax.swing.*;
public class Image extends JComponent {
@Override
public void paintComponent(Graphics pinceau) {
Graphics secondPinceau = pinceau.create();
Image img = Toolkit.getDefaultToolkit().getImage("vaisseau.png");
secondPinceau.drawImage(img, 0, 0, this);
}
}

Binary file not shown.

View File

@@ -0,0 +1,6 @@
public class Main {
public static void main(String[] args) {
Fenetre fenetre = new Fenetre();
fenetre.setVisible(true);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 718 B