35 lines
861 B
Java
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;
|
||
|
}
|
||
|
|
||
|
}
|