From 7ba4f3683ade1cf7ab693260139c09cee3d12001 Mon Sep 17 00:00:00 2001 From: mohamed taarit <mohamed.taarit.etu@univ-lille.fr> Date: Thu, 5 Sep 2024 11:06:25 +0200 Subject: [PATCH] ajout de quelques retouches pour la barre de vie --- src/main/java/bitFight/Level.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/bitFight/Level.java b/src/main/java/bitFight/Level.java index 5a1d94b..114b3fe 100644 --- a/src/main/java/bitFight/Level.java +++ b/src/main/java/bitFight/Level.java @@ -80,8 +80,13 @@ public class Level{ 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); + double pourcentage = (this.player.getCurrentHealth()/this.player.getMaxHealth())*100; + 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.err.println( (int) this.player.getCurrentHealth() + "/" + (int) this.player.getMaxHealth()); -- GitLab