Habillage barre de vie + timer qui fonctionne

This commit is contained in:
Antoine 2021-06-17 01:11:35 +02:00
parent 9ff78c3382
commit c4e3c9623d
7 changed files with 27 additions and 19 deletions

View File

@ -17,7 +17,7 @@ public class Camera {
this.aspectRatio = aspectRatio; this.aspectRatio = aspectRatio;
this.engine = engine; this.engine = engine;
float ar = aspectRatio.y / aspectRatio.x; float ar = aspectRatio.y / aspectRatio.x;
ObjectGl.projection = Matrix4f.orthographic(-dimension, dimension, -dimension * ar, dimension * ar, 0.1f, 100.0f); ObjectGl.projection = Matrix4f.orthographic(-dimension, dimension, -dimension * ar, dimension * ar, 0.1f, 1000.0f);
} }
public void zoom(float zoomFactor){ public void zoom(float zoomFactor){

View File

@ -93,7 +93,8 @@ public class UIElementText extends UIDummy{
if (background != null){ if (background != null){
background.resetTransform(); background.resetTransform();
background.scale(new Vector3f(this.scalingFactor, this.scalingFactor, 1f)); background.scale(new Vector3f(this.scalingFactor, this.scalingFactor, 1f));
background.translate(new Vector3f(x, y)); background.translate(new Vector3f(x, y, this.zPos - 1f));
background.translate(new Vector3f(- engine.getTransformationView().x, - engine.getTransformationView().y));
} }
} }

View File

@ -40,20 +40,18 @@ public class Matrix4f {
} }
public static Matrix4f translate(Vector3f vector){ public static Matrix4f translate(Vector3f vector){
Matrix4f result= identity(); Matrix4f result = identity();
result.elements[0 + 3*4] = vector.x; result.elements[0 + 3*4] = vector.x;
result.elements[1 + 3*4] = vector.y; result.elements[1 + 3*4] = vector.y;
result.elements[2 + 3*4] = vector.z; result.elements[2 + 3*4] = vector.z;
return result; return result;
} }
public static Matrix4f scale(Vector3f vector){ public static Matrix4f scale(Vector3f vector){
Matrix4f result= identity(); Matrix4f result = identity();
result.elements[0 + 0*4] = vector.x; result.elements[0 + 0*4] = vector.x;
result.elements[1 + 1*4] = vector.y; result.elements[1 + 1*4] = vector.y;
result.elements[2 + 2*4] = vector.z; result.elements[2 + 2*4] = vector.z;
return result; return result;
} }

View File

@ -10,13 +10,6 @@ import static org.lwjgl.glfw.GLFW.glfwGetTime;
*/ */
public class ObjectGl { public class ObjectGl {
/**
* STATE CONST DECLARATION
*/
public static final int DEFAULT = 0, STICK_BOTTOM = 1, STICK_TOP = 2;
private int stick_state;
protected VertexArray vertexArray; protected VertexArray vertexArray;
protected Shader shader; protected Shader shader;
protected Matrix4f transform; protected Matrix4f transform;
@ -82,7 +75,6 @@ public class ObjectGl {
this.scalingFactor = 1; this.scalingFactor = 1;
this.transform = Matrix4f.identity(); this.transform = Matrix4f.identity();
this.scale(new Vector3f(size, size,1.0f)); this.scale(new Vector3f(size, size,1.0f));
this.stick_state = DEFAULT;
this.useTime = false; this.useTime = false;
// use different shader for each set of option // use different shader for each set of option

View File

@ -185,7 +185,9 @@ public class match {
System.out.println("P2 Controller: " + gamepad2.getGamepadName()); System.out.println("P2 Controller: " + gamepad2.getGamepadName());
} }
// GUI setup /*
GUI Setup
*/
coordP1 = new UIElementText("objP1: " + objP1.getXPos() + ":" + objP1.getYPos() + " P1: " + p1.getPosX() +":" + p1.getPosY(), 5f, 0f, 0.2f, 70f, engine); coordP1 = new UIElementText("objP1: " + objP1.getXPos() + ":" + objP1.getYPos() + " P1: " + p1.getPosX() +":" + p1.getPosY(), 5f, 0f, 0.2f, 70f, engine);
coordP1.setBackground(new Vector3f(0f,0f,0f)); coordP1.setBackground(new Vector3f(0f,0f,0f));
engine.add_uiElement(coordP1); engine.add_uiElement(coordP1);
@ -194,14 +196,26 @@ public class match {
engine.add_uiElement(coordP2); engine.add_uiElement(coordP2);
// Barre de vie // Barre de vie
healthBarP1Obj = new HorizontalProgressBar(80f, 8.5f, 0.4f, 100f, p1.getCurrentHP(), p1.getMaxHP(), false); healthBarP1Obj = new HorizontalProgressBar(80f, 8.5f, 0.4f, 100f, p1.getCurrentHP(), p1.getMaxHP(), false);
healthBarP1 = new UIElement(healthBarP1Obj, 0.01f, 0.990f, engine); healthBarP1 = new UIElement(healthBarP1Obj, 0.0138f, 0.980f, engine);
healthBarP2Obj = new HorizontalProgressBar(80f, 8.5f, 0.4f, 100f, p2.getCurrentHP(), p2.getMaxHP(), true); healthBarP2Obj = new HorizontalProgressBar(80f, 8.5f, 0.4f, 100f, p2.getCurrentHP(), p2.getMaxHP(), true);
healthBarP2 = new UIElement(healthBarP2Obj, 0.565f, 0.990f, engine); healthBarP2 = new UIElement(healthBarP2Obj, 0.563f, 0.980f, engine);
engine.add_uiElement(healthBarP1); engine.add_uiElement(healthBarP1);
engine.add_uiElement(healthBarP2); engine.add_uiElement(healthBarP2);
// Habillage barre de vie
ObjectGl healthBarP1Hab = new ObjectGl(81f, 1f, 1f, 1f, "textures/health_bar.png", null);
healthBarP1Hab.setTextureWrap(0,0, 883, 158);
UIElement healthBarP1HabUI = new UIElement(healthBarP1Hab, 0.005f, 0.995f, engine);
engine.add_uiElement(healthBarP1HabUI);
ObjectGl healthBarP2Hab = new ObjectGl(81f, 1f, 1f, 1f, "textures/health_bar.png", null);
healthBarP2Hab.setTextureWrap(0,0, 883, 158);
healthBarP2Hab.flipTextureWrapH();
UIElement healthBarP2HabUI = new UIElement(healthBarP2Hab, 0.555f, 0.995f, engine);
engine.add_uiElement(healthBarP2HabUI);
// Timer // Timer
timerUI = new UIElementText(timer + "", 10f, 0.45f, 1.0f, 85f, engine); timerUI = new UIElementText(timer + "", 10f, 0.453f, 0.995f, 85f, engine);
engine.add_uiElement(timerUI); engine.add_uiElement(timerUI);
//SetTracking
engine.setCameraTrackingSF3ThirdStrike(objP1, objP2);
while(frameCount < 5940 && engine.getRunning()) { while(frameCount < 5940 && engine.getRunning()) {
ac(acCode); ac(acCode);
@ -346,7 +360,10 @@ public class match {
healthBarP1Obj.setCurrent(p1.getCurrentHP()); healthBarP1Obj.setMax(p1.getMaxHP()); healthBarP1Obj.setCurrent(p1.getCurrentHP()); healthBarP1Obj.setMax(p1.getMaxHP());
healthBarP2Obj.setCurrent(p2.getCurrentHP()); healthBarP2Obj.setMax(p2.getMaxHP()); healthBarP2Obj.setCurrent(p2.getCurrentHP()); healthBarP2Obj.setMax(p2.getMaxHP());
timerUI.setText(timer + ""); timerUI.setText(timer + "");
// Tracking update
engine.cameraTracking();
timer = 99 - frameCount/99;
timeStamp2 = System.currentTimeMillis(); timeStamp2 = System.currentTimeMillis();
while(timeStamp2-timeStamp1<(1000/60)) { while(timeStamp2-timeStamp1<(1000/60)) {
timeStamp2 = System.currentTimeMillis(); timeStamp2 = System.currentTimeMillis();

View File

@ -7,4 +7,4 @@
80 - Barre de vie 80 - Barre de vie
81 - Habillage barre de vie 81 - Habillage barre de vie
85 - Timer 85 - Timer
90 + 1000 +

BIN
textures/health_bar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 560 KiB