Barre de vie + timer

This commit is contained in:
Antoine 2021-06-16 14:20:04 +02:00
parent cbec6fba9d
commit 7432553a70

View File

@ -1,10 +1,12 @@
package gameplay.match;
import engine.Engine;
import engine.gui.UIElement;
import engine.gui.UIElementText;
import engine.input.Button;
import engine.input.GamepadInput;
import engine.math.Vector3f;
import engine.object.HorizontalProgressBar;
import engine.object.ObjectGl;
import engine.object.Sprite;
import gameplay.Characters.Blue.CharacterBlue;
@ -62,6 +64,11 @@ public class match {
// GUI
private static UIElementText coordP1;
private static UIElementText coordP2;
private static UIElement healthBarP1;
private static UIElement healthBarP2;
private static HorizontalProgressBar healthBarP1Obj;
private static HorizontalProgressBar healthBarP2Obj;
private static UIElementText timerUI;
private static ObjectGl objP1,objP2;
private static Engine engine;
@ -141,10 +148,20 @@ public class match {
}
// GUI setup
coordP1 = new UIElementText("objP1: " + objP1.getXPos() + ":" + objP1.getYPos() + " P1: " + p1.getPosX() +":" + p1.getPosY(), 5f, 0f, 1f, 80f, engine);
coordP1 = new UIElementText("objP1: " + objP1.getXPos() + ":" + objP1.getYPos() + " P1: " + p1.getPosX() +":" + p1.getPosY(), 5f, 0f, 0.2f, 80f, engine);
engine.add_uiElement(coordP1);
coordP2 = new UIElementText("objP2: " + objP2.getXPos() + ":" + objP2.getYPos() + " P1: " + p2.getPosX() +":" + p2.getPosY(), 5f, 0f, 0.9f, 80f, engine);
coordP2 = new UIElementText("objP2: " + objP2.getXPos() + ":" + objP2.getYPos() + " P1: " + p2.getPosX() +":" + p2.getPosY(), 5f, 0f, 0.1f, 80f, engine);
engine.add_uiElement(coordP2);
// Barre de vie
healthBarP1Obj = new HorizontalProgressBar(90f, 8.5f, 0.4f, 100f, p1.getCurrentHP(), p1.getMaxHP(), false);
healthBarP1 = new UIElement(healthBarP1Obj, 0.01f, 0.990f, engine);
healthBarP2Obj = new HorizontalProgressBar(90f, 8.5f, 0.4f, 100f, p2.getCurrentHP(), p2.getMaxHP(), true);
healthBarP2 = new UIElement(healthBarP2Obj, 0.565f, 0.990f, engine);
engine.add_uiElement(healthBarP1);
engine.add_uiElement(healthBarP2);
// Timer
timerUI = new UIElementText(timer + "", 10f, 0.45f, 1.0f, 90f, engine);
engine.add_uiElement(timerUI);
while(frameCount < 5940 && engine.getRunning()) {
ac(acCode);
@ -286,6 +303,10 @@ public class match {
// GUI update here
coordP1.setText("objP1: " + objP1.getXPos() + ":" + objP1.getYPos() + " P1: " + p1.getPosX() +":" + p1.getPosY());
coordP2.setText("objP2: " + objP2.getXPos() + ":" + objP2.getYPos() + " P2: " + p2.getPosX() +":" + p2.getPosY());
healthBarP1Obj.setCurrent(p1.getCurrentHP()); healthBarP1Obj.setMax(p1.getMaxHP());
healthBarP2Obj.setCurrent(p2.getCurrentHP()); healthBarP2Obj.setMax(p2.getMaxHP());
timerUI.setText(timer + "");
timeStamp2 = System.currentTimeMillis();
while(timeStamp2-timeStamp1<(1000/60)) {
timeStamp2 = System.currentTimeMillis();