Started adjusting the handling of Inputs
This commit is contained in:
parent
d6c35e24c5
commit
e02acbcf5c
5
GamePlay/Actions/Attack.java
Normal file
5
GamePlay/Actions/Attack.java
Normal file
@ -0,0 +1,5 @@
|
||||
package Actions;
|
||||
|
||||
public class Attack {
|
||||
|
||||
}
|
19
GamePlay/input/Button.java
Normal file
19
GamePlay/input/Button.java
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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};
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
||||
}
|
45
GamePlay/input/Inputs.java
Normal file
45
GamePlay/input/Inputs.java
Normal 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user