Skip to content
Snippets Groups Projects
Commit 4d42483c authored by Maxime Wallart's avatar Maxime Wallart :speech_balloon:
Browse files

update deplacements

parents c979be3b 378678ca
Branches
No related tags found
No related merge requests found
package main;
public enum Direction {
HAUT, GAUCHE, BAS, DROITE;
}
package main; package main;
import java.util.Scanner;
import units.Paysant; import units.Paysant;
public class Main { public class Main {
private static Joueur winner; private static Joueur winner = new Joueur("Winner");
private int actionPoint; private int actionPoint;
public static void main(String[] args) { public static void main(String[] args) {
...@@ -18,10 +20,13 @@ public class Main { ...@@ -18,10 +20,13 @@ public class Main {
Plateau plateau = new Plateau(); Plateau plateau = new Plateau();
int x = 11; int x = 11;
int y = 0; int y = 10;
plateau.getCase(x, y).setUnite(new Paysant(x, y, plateau, winner)); plateau.getCase(x, y).setUnite(new Paysant(x, y, plateau, winner));
//winner.ajoutUnit(plateau.getCase(x, y).getUnite());
Affichage.affichage(plateau); Affichage.affichage(plateau);
plateau.getCase(x, y).getUnite().move(Direction.HAUT); //plateau.getCase(x, y).getUnite().move(deplacement());
System.out.println(winner.getArmee().get(0));
winner.getArmee().get(0).move(deplacement());
System.out.println('\n'); System.out.println('\n');
Affichage.affichage(plateau); Affichage.affichage(plateau);
<<<<<<< HEAD <<<<<<< HEAD
...@@ -34,7 +39,21 @@ public class Main { ...@@ -34,7 +39,21 @@ public class Main {
>>>>>>> 6e6d8e1d075a8855972540815248afce1757f9e0 >>>>>>> 6e6d8e1d075a8855972540815248afce1757f9e0
} }
<<<<<<< HEAD
public Joueur Game (Joueur[] joueurs) { public Joueur Game (Joueur[] joueurs) {
=======
public static char deplacement() {
Scanner sc = new Scanner(System.in);
System.out.println("Veuillez choisir une direction");
while (!sc.hasNext("[zqsd]")) {
System.out.println("Cette touche n'est pas acceptés, veuillez réessayer");
sc.next();
}
return sc.next().charAt(0);
}
private Joueur Game (Joueur[] joueurs) {
>>>>>>> Maxime
boolean gameEnd = false; boolean gameEnd = false;
while(gameEnd){ while(gameEnd){
for (Joueur currentPlayer : joueurs) { for (Joueur currentPlayer : joueurs) {
......
...@@ -2,7 +2,6 @@ package units; ...@@ -2,7 +2,6 @@ package units;
import items.Items; import items.Items;
import main.Case; import main.Case;
import main.Direction;
import main.Event; import main.Event;
import main.Joueur; import main.Joueur;
import main.Plateau; import main.Plateau;
...@@ -30,6 +29,7 @@ public abstract class Unite { ...@@ -30,6 +29,7 @@ public abstract class Unite {
this.x = x; this.x = x;
this.y = y; this.y = y;
this.joueur = joueur; this.joueur = joueur;
this.joueur.ajoutUnit(this);
this.item = null; this.item = null;
} }
...@@ -125,26 +125,26 @@ public abstract class Unite { ...@@ -125,26 +125,26 @@ public abstract class Unite {
return false; return false;
} }
//à voir le type //à voir le type
public boolean move(Direction d) { public boolean move(char c) {
if(d == Direction.BAS) { if(c == 's') {
if (updatePosition(x+1,y)) { if (updatePosition(x+1,y)) {
this.plateau.getCase(x, y).setUnite(null); this.plateau.getCase(x, y).setUnite(null);
return true; return true;
} }
} }
else if(d == Direction.DROITE) { else if(c == 'd') {
if (updatePosition(x,y+1)) { if (updatePosition(x,y+1)) {
this.plateau.getCase(x, y).setUnite(null); this.plateau.getCase(x, y).setUnite(null);
return true; return true;
} }
} }
else if(d == Direction.GAUCHE) { else if(c == 'q') {
if (updatePosition(x,y-1)) { if (updatePosition(x,y-1)) {
this.plateau.getCase(x, y).setUnite(null); this.plateau.getCase(x, y).setUnite(null);
return true; return true;
} }
} }
else if(d == Direction.HAUT) { else if(c == 'z') {
if (updatePosition(x-1, y)) { if (updatePosition(x-1, y)) {
this.plateau.getCase(x, y).setUnite(null); this.plateau.getCase(x, y).setUnite(null);
return true; return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment