From ec37cab5ef8ab30ab0584198d4b60fa24e926dfb Mon Sep 17 00:00:00 2001 From: Antoine Date: Sat, 19 Jun 2021 14:39:36 +0200 Subject: [PATCH] =?UTF-8?q?UIInputList=20affiche=20mtn=20seulement=20les?= =?UTF-8?q?=20nouvelles=20touches=20enfonc=C3=A9es=20cette=20frame?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/engine/gui/UIInputList.java | 27 +++++++++++++++------------ src/gameplay/match/match.java | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/engine/gui/UIInputList.java b/src/engine/gui/UIInputList.java index 57fc782..ec6b1bc 100644 --- a/src/engine/gui/UIInputList.java +++ b/src/engine/gui/UIInputList.java @@ -19,6 +19,8 @@ public class UIInputList extends UIDummy{ private List listIcon; private ControllerPromptTextureLoader tex; + private boolean[] tab; + public UIInputList(InputBuffer inputBuffer, float size, float posX, float posY, float posZ, Engine engine){ this.engine = engine; this.camera = engine.getCamera(); @@ -28,6 +30,7 @@ public class UIInputList extends UIDummy{ this.zPos = posZ; this.inputBuffer = inputBuffer; this.tex = new ControllerPromptTextureLoader(); + this.tab = new boolean[8]; } public void init(){ @@ -57,39 +60,42 @@ public class UIInputList extends UIDummy{ public void createNextButton(int i){ boolean[] input = inputBuffer.getInputList()[i].getTab(); ObjectGl obj = null; - if (input[0]) { + if (input[0] && !tab[0]) { // UP obj = new ObjectGl(100f, 10f, 10f, 10f, null, null); obj.setTexture(tex.up); - } if (input[1]){ + } if (input[1] && !tab[1]){ // DOWN obj = new ObjectGl(100f, 10f, 10f, 10f, null, null); obj.setTexture(tex.down); - } if (input[2]){ //Pour l'instant on fait comme si l'avant était toujours à droite donc arrière à gauche + } if (input[2] && !tab[2]){ //Pour l'instant on fait comme si l'avant était toujours à droite donc arrière à gauche // BACK obj = new ObjectGl(100f, 10f, 10f, 10f, null, null); obj.setTexture(tex.left); - } if (input[3]){ + } if (input[3] && !tab[3]){ // FORWARD obj = new ObjectGl(100f, 10f, 10f, 10f, null, null); obj.setTexture(tex.right); - } if (input[4]){ + } if (input[4] && !tab[4]){ // A obj = new ObjectGl(100f, 10f, 10f, 10f, null, null); obj.setTexture(tex.X); - } if (input[5]){ + } if (input[5] && !tab[5]){ // B obj = new ObjectGl(100f, 10f, 10f, 10f, null, null); obj.setTexture(tex.A); - } if (input[6]){ + } if (input[6] && !tab[6]){ // C obj = new ObjectGl(100f, 10f, 10f, 10f, null, null); obj.setTexture(tex.Y); - } if (input[7]){ + } if (input[7] && !tab[7]){ // D obj = new ObjectGl(100f, 10f, 10f, 10f, null, null); obj.setTexture(tex.B); } + for (int k = 0; k < 8; k++){ + tab[k] = input[k]; + } if (obj != null){ listIcon.add(obj); obj.setShader("shaders/ObjectGlTex/vert.glsl", "shaders/ObjectGlTex/frag.glsl"); @@ -101,15 +107,12 @@ public class UIInputList extends UIDummy{ createNextButton(this.posBuffer); - if(listIcon.size() > 30){ + if(listIcon.size() > 15){ engine.remove_objectGl(listIcon.get(0)); listIcon.remove(listIcon.get(0)); } } - /** - * Encules les perfs :( le problème c'est forcement le chargement des textures - */ public void update(){ this.posBuffer = this.inputBuffer.getPos(); createButtonList(); diff --git a/src/gameplay/match/match.java b/src/gameplay/match/match.java index 2ca4a7f..bd457ca 100644 --- a/src/gameplay/match/match.java +++ b/src/gameplay/match/match.java @@ -106,7 +106,7 @@ public class match { objP1.getShadow().translate(new Vector3f(0f,p1.getPosY(),0)); objP2.getShadow().translate(new Vector3f(0f,p2.getPosY(),0)); // Crée l'InputList - inputListP1 = new UIInputList(inputsP1, 10f, 0f, 0.3f, 110f, engine); + inputListP1 = new UIInputList(inputsP1, 10f, 0f, 0.85f, 110f, engine); engine.add_uiElement(inputListP1); inputListP1.init(); }