Skip to content
Snippets Groups Projects
Commit 262d8db0 authored by Kellian Mirey's avatar Kellian Mirey
Browse files

Implemented Health bar

parent 55e87c9a
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,6 @@ package bitFight;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.ArrayList;
public enum Attack implements Action {
PUNCH(10, "punch", ActionHeight.HIGH, 10),
......
......@@ -7,8 +7,13 @@ import java.io.InputStreamReader;
public class Display {
public static Level level;
public static int row = 1;
public Display(Level l){
this.level = l;
}
public static void clearScreen() {
System.out.print("\033[H\033[2J");
}
......@@ -31,15 +36,16 @@ public class Display {
}
public static void goToDialogBox(){
setCursorPos(1,0);
setCursorPos(row+6,0);
//System.out.flush();
}
public static void clearDialogBox(){
clearScreen();
setCursorPos(row, 0);
printDialogBox();
setCursorPos(row,0);
level.displayLifePoints();
goToDialogBox();
}
......@@ -50,7 +56,7 @@ public class Display {
dialogBox = loadTextFile("assets/DialogBox.text");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
e.getMessage();
}
System.out.println(dialogBox);
}
......
......@@ -75,9 +75,10 @@ public class Level{
// affiche la jauge de vie
public void displayLifePoints (){
public void displayLifePoints (){
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);
for (int indice = 0; indice < ((this.player.getCurrentHealth()/this.player.getMaxHealth())*100)/2; indice ++){
System.out.print(Terminal.GREEN+ "▬"+ Terminal.RESET);
......
......@@ -20,6 +20,8 @@ class Main {
Level level = new Level(1, player, enemy);
GameData gamedata = Save.loadObject("res/gamedata");
Display display = new Display(level);
if (gamedata != null) {
player = gamedata.getPlayer();
level = gamedata.getLevelReached();
......
package bitFight;
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