Skip to content

Commit

Permalink
Changes to be committed:
Browse files Browse the repository at this point in the history
	modified:   Test/PacManpackage/PacManTest.java
	modified:   bin/PacManpackage/MatrixPanel.class
	modified:   bin/PacManpackage/Point.class
	modified:   src/PacManpackage/MatrixPanel.java
	modified:   src/PacManpackage/Point.java
  • Loading branch information
RaykeshR committed Jun 10, 2024
1 parent 4b86c85 commit f8c9ceb
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 43 deletions.
8 changes: 8 additions & 0 deletions Test/PacManpackage/PacManTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ void test2() {
Assertions.assertFalse(A>10, "getRandomNumber");
}
}
@Test
void test3() {
PacMan p = new PacMan();
p.setVisible(true);
p.main(null);
//TODO
}



}
Binary file modified bin/PacManpackage/MatrixPanel.class
Binary file not shown.
Binary file modified bin/PacManpackage/Point.class
Binary file not shown.
6 changes: 4 additions & 2 deletions src/PacManpackage/MatrixPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ protected void paintComponent(Graphics g) {
}

// Draw points for cells with value 2
for (Point point : points) {
List<Point> points3 = new ArrayList<>(points); // copie de la liste pour enlever des bug
for (Point point : points3) {
// if (point.getX()!=0 || point.getY()!=0) {
JLabel label = point.getLabel();
label.setLocation(point.getX() * size+3, point.getY() * size+3);
Expand Down Expand Up @@ -84,7 +85,8 @@ public void removePoint(Point point) {
* @return
*/
public Point getPoint(int x, int y) {
for (Point point : points) {
List<Point> points2 = new ArrayList<>(points); // copie de la liste pour enlever des bug du à une écriture et lecture en simultané.
for (Point point : points2) {
if (point.getX() == x && point.getY() == y) {
return point;
}
Expand Down
82 changes: 41 additions & 41 deletions src/PacManpackage/Point.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ public class Point {
private final int offsetY = 105;
// private boolean EnCoursDeDigestion;
// // Position dans le Plateau (Matrice)
// int Px,Py;
int Px,Py;


public Point(int x, int y) {
this.x = x;
this.y = y;
this.x = x;Px=x;
this.y = y;Py=y;
ImageIcon icon = new ImageIcon(this.getClass().getResource("/PacManpackage/rond-jaune.png"));
icon = resizeImageIcon(icon, 3, 3);
label = new JLabel(icon);
Expand Down Expand Up @@ -114,44 +114,44 @@ public int getY() {
// }
// return points;
// }
//
// private int count(int[][] matrix, int value) {
// int count = 0;
// for (int i = 0; i < matrix.length; i++) {
// for (int j = 0; j < matrix[i].length; j++) {
// if (matrix[i][j] == value) {
// count++;
// }
// }
// }
// return count;
// }
//
//
// /**
// *
// * renvoie les objets de la classe point correspondont aux Gros point sur le plateau.
// * n=10
// */
// public Point[] LesBonus(int n) {
// Plateau get = new Plateau();
// int[][] P = get.getPlateau();
// int nombreELements = count(P, 4);
// Point[] points = new Point[nombreELements];
// int index = 0;
// for (int i = 0; i < P.length; i++) {
// for (int j = 0; j < P[i].length; j++) {
// if (P[i][j] == 4) {
// points[index] = new Point(i * n, j * n);
// points[index].Px = i;
// points[index].Py = j;
// index++;
// }
// }
// }
// return points;
// }
//

private int count(int[][] matrix, int value) {
int count = 0;
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[i].length; j++) {
if (matrix[i][j] == value) {
count++;
}
}
}
return count;
}


/**
*
* renvoie les objets de la classe point correspondont aux Gros point sur le plateau.
* n=10
*/
public Point[] LesBonus(int n) {
Plateau get = new Plateau();
int[][] P = get.getPlateau();
int nombreELements = count(P, 4);
Point[] points = new Point[nombreELements];
int index = 0;
for (int i = 0; i < P.length; i++) {
for (int j = 0; j < P[i].length; j++) {
if (P[i][j] == 4) {
points[index] = new Point(i * n, j * n);
points[index].Px = i;
points[index].Py = j;
index++;
}
}
}
return points;
}



}

0 comments on commit f8c9ceb

Please sign in to comment.