ajout de plein de fonction et suppression des anciennes classes

This commit is contained in:
2024-05-08 23:47:00 +02:00
parent 5743206062
commit 6480a90d85
7 changed files with 103 additions and 127 deletions

View File

@@ -1,17 +1,46 @@
package personnages;
import java.util.Scanner;
public class Player extends Personnage {
public Player(int size, int[] coordinate) {
super(size, coordinate);
private int[] coordinate;
/**
* <p>le constructor definie les coordonnées de la tête et defini n.
*
* @param n est une variable qui contient le nombre de
* tour avant l'augmentation de taille.
* @param coordinate est un array de <strong>2 entiers</strong>
* qui est <strong>{x, y}</strong>
*/
public Player(int n, int[] coordinate) {
super(n, coordinate);
this.coordinate = coordinate;
}
public void changeCoordinate(int keys) {
public void changeCoordinate() {
Scanner scanner = new Scanner(System.in);
char value;
do {
value = scanner.nextLine().charAt(0);
} while (!moveCoordinate((int)value));
scanner.close();
}
public int[] getCoordinate() {
return coordinate;
}
private boolean moveCoordinate(int keys) {
switch (keys) {
case 77: Mouvement.HAUT.editCoordinate(coordinate); // w
case 73: Mouvement.BAS.editCoordinate(coordinate); // s
case 61: Mouvement.GAUCHE.editCoordinate(coordinate); // a
case 64: Mouvement.DROITE.editCoordinate(coordinate); // d
default: break;
case 119: Mouvement.HAUT.editCoordinate(coordinate); break;
case 115: Mouvement.BAS.editCoordinate(coordinate); break;
case 97: Mouvement.GAUCHE.editCoordinate(coordinate); break;
case 100: Mouvement.DROITE.editCoordinate(coordinate); break;
default: return false;
}
return true;
}
}