Skip to content
Snippets Groups Projects
Commit fad0fc7b authored by Camille Okubo's avatar Camille Okubo
Browse files
parents c8a70585 0f79a64d
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,6 @@ package bitFight; ...@@ -2,7 +2,6 @@ package bitFight;
import java.time.Duration; import java.time.Duration;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList;
public enum Attack implements Action { public enum Attack implements Action {
PUNCH(10, "punch", ActionHeight.HIGH, 10), PUNCH(10, "punch", ActionHeight.HIGH, 10),
......
...@@ -7,8 +7,13 @@ import java.io.InputStreamReader; ...@@ -7,8 +7,13 @@ import java.io.InputStreamReader;
public class Display { public class Display {
public static Level level;
public static int row = 1; public static int row = 1;
public Display(Level l){
this.level = l;
}
public static void clearScreen() { public static void clearScreen() {
System.out.print("\033[H\033[2J"); System.out.print("\033[H\033[2J");
} }
...@@ -31,15 +36,16 @@ public class Display { ...@@ -31,15 +36,16 @@ public class Display {
} }
public static void goToDialogBox(){ public static void goToDialogBox(){
setCursorPos(1,0); setCursorPos(row+6,0);
//System.out.flush(); //System.out.flush();
} }
public static void clearDialogBox(){ public static void clearDialogBox(){
clearScreen(); clearScreen();
setCursorPos(row, 0);
printDialogBox(); printDialogBox();
setCursorPos(row,0);
level.displayLifePoints();
goToDialogBox(); goToDialogBox();
} }
...@@ -50,7 +56,7 @@ public class Display { ...@@ -50,7 +56,7 @@ public class Display {
dialogBox = loadTextFile("assets/DialogBox.text"); dialogBox = loadTextFile("assets/DialogBox.text");
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.getMessage();
} }
System.out.println(dialogBox); System.out.println(dialogBox);
} }
......
...@@ -75,12 +75,18 @@ public class Level{ ...@@ -75,12 +75,18 @@ public class Level{
// affiche la jauge de vie // affiche la jauge de vie
public void displayLifePoints (){ public void displayLifePoints (){
System.err.println(); System.err.println();
System.out.println("\t \t " +this.player.getName()); System.out.println("Player " + this.player.getName());
System.out.println();
System.out.print(Terminal.GREEN+" \t current health "+Terminal.RESET); System.out.print(Terminal.GREEN+" \t current health "+Terminal.RESET);
for (int indice = 0; indice < ((this.player.getCurrentHealth()/this.player.getMaxHealth())*100)/2; indice ++){ double pourcentage = (this.player.getCurrentHealth()/this.player.getMaxHealth())*100;
System.out.print(Terminal.GREEN+ "▬"+ Terminal.RESET); for (int indice = 0; indice < pourcentage/2; indice ++){
if (pourcentage<=50){
System.out.print(Terminal.RED+"▬");
}else{
System.out.print(Terminal.GREEN+ "▬"+Terminal.RESET);
}
} }
System.out.print(" "); System.out.print(" ");
System.err.println( (int) this.player.getCurrentHealth() + "/" + (int) this.player.getMaxHealth()); System.err.println( (int) this.player.getCurrentHealth() + "/" + (int) this.player.getMaxHealth());
...@@ -112,7 +118,7 @@ public class Level{ ...@@ -112,7 +118,7 @@ public class Level{
public void playerHasEnergy(Attack attack) { public void playerHasEnergy(Attack attack) {
this.ennemy.damage(attack.getDamage() * player.getAttackMultiplier()); this.ennemy.damage(attack.getDamage() * player.getAttackMultiplier());
player.exhaust(attack.getEnergyCost()); player.exhaust(attack.getEnergyCost());
System.out.println("You're using " + attack.getName() + "! You lose " + attack.getEnergyCost() + " energy points"); System.out.println("You're using " + attack.getName() + "! You lose " + (int) attack.getEnergyCost() + " energy points");
} }
// affiche les règles du jeu // affiche les règles du jeu
......
...@@ -20,6 +20,8 @@ class Main { ...@@ -20,6 +20,8 @@ class Main {
Level level = new Level(1, player, enemy); Level level = new Level(1, player, enemy);
GameData gamedata = Save.loadObject("res/gamedata"); GameData gamedata = Save.loadObject("res/gamedata");
Display display = new Display(level);
if (gamedata != null) { if (gamedata != null) {
player = gamedata.getPlayer(); player = gamedata.getPlayer();
level = gamedata.getLevelReached(); level = gamedata.getLevelReached();
...@@ -64,13 +66,13 @@ class Main { ...@@ -64,13 +66,13 @@ class Main {
Random rand = new Random(); Random rand = new Random();
// arrivée de l'ennemi
level.ennemyShowing();
Input input = new Input(); Input input = new Input();
input.newInput(); input.newInput();
Display.goToDialogBox(); Display.goToDialogBox();
// arrivée de l'ennemi
level.ennemyShowing();
if (input.getInput().equals("a")) { if (input.getInput().equals("a")) {
...@@ -137,6 +139,11 @@ class Main { ...@@ -137,6 +139,11 @@ class Main {
level.displayEndOfLevel(); level.displayEndOfLevel();
} }
if (player.isDead()) {
level.playerDying();
level.gameOver();
}
} }
} }
......
package bitFight; package bitFight;
import java.io.IOException; import java.io.IOException;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment