From 5a32d5d1fb3e425d1a1677fcc1663dfaf99ad4be Mon Sep 17 00:00:00 2001 From: Azra Victor Date: Wed, 16 Jun 2021 11:34:35 +0200 Subject: [PATCH] Made input recognition more accurate. Adjusted light rising punch movement. --- .../Characters/Blue/BlueSpecials.java | 6 ++-- src/gameplay/input/InputBuffer.java | 2 +- src/gameplay/input/Inputs.java | 32 +++++++++++++++++-- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/gameplay/Characters/Blue/BlueSpecials.java b/src/gameplay/Characters/Blue/BlueSpecials.java index b802537..f5a0cac 100644 --- a/src/gameplay/Characters/Blue/BlueSpecials.java +++ b/src/gameplay/Characters/Blue/BlueSpecials.java @@ -106,7 +106,7 @@ public class BlueSpecials { /* frame creation */ - Frame f = new Frame(3.0,3.0,phb,ahb,pthb,athb,pushB, + Frame f = new Frame(8.0,5.0,phb,ahb,pthb,athb,pushB, //cancels (in order : normal, special, jump, move, dash) false,false,false,false,false); f.setSpriteWrap(714,0,102,120); @@ -139,7 +139,7 @@ public class BlueSpecials { /* frame creation */ - Frame f = new Frame(3.0,0.0,phb,ahb,pthb,athb,pushB, + Frame f = new Frame(8.0,0.0,phb,ahb,pthb,athb,pushB, //cancels (in order : normal, special, jump, move, dash) false,false,false,false,false); f.setSpriteWrap(714,0,102,120); @@ -172,7 +172,7 @@ public class BlueSpecials { /* frame creation */ - Frame f = new Frame(-3.0,0.0,phb,ahb,pthb,athb,pushB, + Frame f = new Frame(-8.0,0.0,phb,ahb,pthb,athb,pushB, //cancels (in order : normal, special, jump, move, dash) false,false,false,false,false); f.setSpriteWrap(714,0,102,120); diff --git a/src/gameplay/input/InputBuffer.java b/src/gameplay/input/InputBuffer.java index 097cb4d..a587e03 100644 --- a/src/gameplay/input/InputBuffer.java +++ b/src/gameplay/input/InputBuffer.java @@ -118,7 +118,7 @@ public class InputBuffer { else {frameToCheck = startFrameCount - backCounter;} boolean search = true; while(ret && search) { - if(this.inputList[frameToCheck].containsButtonTab(command[i])) { + if(this.inputList[frameToCheck].containsButtonTab2(command[i])) { ret = true; search = false; } else { diff --git a/src/gameplay/input/Inputs.java b/src/gameplay/input/Inputs.java index a013dfe..f910b5f 100644 --- a/src/gameplay/input/Inputs.java +++ b/src/gameplay/input/Inputs.java @@ -2,6 +2,9 @@ package gameplay.input; import engine.input.GamepadInput; import engine.input.InputConst; +import gameplay.input.ButtonIG; + +import static gameplay.input.ButtonIG.*; /** * The class handling the parsing of one input. @@ -60,6 +63,31 @@ public class Inputs { } return true; } + + /** + * Check if a number of inputs are contained simultaneously, in the form of an array of Buttons. + * Contrary to the other containsButtonTab, will check that only these specified buttons are pressed. + * @param bs a number of inputs. Check if those are contained in this + * @return true if all inputs of in are also in this + */ + public boolean containsButtonTab2(ButtonIG[] bs) { + ButtonIG[] directions = {DOWN,FORWARD,UP,BACK}; + ButtonIG[] buttons = {A,B,C,D}; + for(ButtonIG d : directions) { + if(!this.containsInput(d) && buttonTabContainsButton(bs, d)) { return false;} + if(this.containsInput(d) && !buttonTabContainsButton(bs, d)) { return false;} + } + for(ButtonIG d : buttons) { + if(!this.containsInput(d) && buttonTabContainsButton(bs, d)) { return false;} + if(this.containsInput(d) && !buttonTabContainsButton(bs, d)) { return false;} + } + return true; + } + + private static boolean buttonTabContainsButton(ButtonIG[] bs, ButtonIG b) { + for (int i = 0; i < bs.length; i++) { if(bs[i] == b) return true; } + return false; + } public boolean[] getInputs() { return this.tab; @@ -67,9 +95,9 @@ public class Inputs { public void recordFromGamepad(GamepadInput pad, boolean facesRight) { this.tab[ButtonIG.UP.toInt()] = pad.checkPressed(InputConst.up); - this.tab[ButtonIG.DOWN.toInt()] = pad.checkPressed(InputConst.down); + this.tab[DOWN.toInt()] = pad.checkPressed(InputConst.down); this.tab[ButtonIG.BACK.toInt()] = (pad.checkPressed(InputConst.left) && facesRight) || (pad.checkPressed(InputConst.right)&&!facesRight); - this.tab[ButtonIG.FORWARD.toInt()] = (pad.checkPressed(InputConst.right) && facesRight) || (pad.checkPressed(InputConst.left) && !facesRight); + this.tab[FORWARD.toInt()] = (pad.checkPressed(InputConst.right) && facesRight) || (pad.checkPressed(InputConst.left) && !facesRight); this.tab[ButtonIG.A.toInt()] = pad.checkPressed(InputConst.buttonX); this.tab[ButtonIG.B.toInt()] = pad.checkPressed(InputConst.buttonA); this.tab[ButtonIG.C.toInt()] = pad.checkPressed(InputConst.buttonY);