Started adjusting the handling of Inputs

This commit is contained in:
no 2021-05-27 13:43:42 +02:00
parent d6c35e24c5
commit e02acbcf5c
5 changed files with 69 additions and 12 deletions

View File

@ -0,0 +1,5 @@
package Actions;
public class Attack {
}

View File

@ -0,0 +1,19 @@
package input;
public enum Button {
UP, DOWN, LEFT, RIGHT, A, B, C, D;
public int toInt() {
switch (this) {
case UP : return 0;
case DOWN : return 1;
case LEFT : return 2;
case RIGHT : return 3;
case A : return 4;
case B : return 5;
case C : return 6;
case D : return 7;
default : return -1;
}
}
}

View File

@ -2,7 +2,6 @@ package input;
public class InputBuffer {
private static final int numberOfInputs = 8;
private static final Boolean[] baseInputs = {false,false,false,false,false,false,false,false};
/**

View File

@ -1,11 +0,0 @@
package input;
import java.util.ArrayList;
public class Input_Attack {
/*
* The list of all input needed to make an attack
*/
//public ArrayList<Input> input_list;
}

View File

@ -0,0 +1,45 @@
package input;
/**
* The class handling the parsing of one input.
* @author Victor
*
*/
public class Inputs {
private static final int numberOfInputs = 8;
private static boolean[] tab;
public Inputs() {
this.tab = new boolean[numberOfInputs];
for(int i = 0; i < numberOfInputs; i ++) {
this.tab[i] = false;
}
}
/**
* record one input
* @param i the integer value corresponding to the tab location
*/
public void recordOneInput(int i) {
try {
this.tab[i] = true;
} catch (ArrayIndexOutOfBoundsException e) {
//TODO : what do we do here ? Error message ?
}
}
/**
* Check if a specific input (for example UP) has been recorded
* @param i the integer value corresponding to the input
* @return
*/
public boolean containsInput(Button b) {
return this.tab[b.toInt()];
}
public boolean[] getInputs() {
return this.tab;
}
}