Files
DEV/DEV2.1/TP12/04_Trainee/GestionGrille.java
Simoes Lukas fe693705bf TP
2025-03-27 13:35:54 +01:00

35 lines
861 B
Java

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;
}
}