TP
This commit is contained in:
35
DEV2.1/TP12/04_Trainee/GestionGrille.java
Normal file
35
DEV2.1/TP12/04_Trainee/GestionGrille.java
Normal 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;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user