gamepadInput updated

This commit is contained in:
Léo 2021-05-31 16:54:02 +02:00
parent 888e5825ba
commit 00a19177c7
2 changed files with 30 additions and 24 deletions

View File

@ -24,7 +24,7 @@ public class Engine {
private final List<ObjectGl> objectsGl;
private final static int buttonA=0, buttonB=1, buttonX=3, buttonY=4;
private final static int buttonA=0, buttonB=1, buttonX=2, buttonY=3, LB = 4, RB = 5, select = 6, start = 7, L_JoystickClick = 8, R_JoystickClick =9, Up = 10, right = 11, down = 12, left = 13;
private boolean running;
@ -218,6 +218,11 @@ public class Engine {
if (present) { //sprite //bindings
gamepadInput.gamepadInput(zangief, speed, buttonA, buttonB, buttonX, buttonY);
System.out.println( " \n A :" + gamepadInput.buttonA_pressed +
" \n B :" + gamepadInput.buttonB_pressed +
" \n Y :" + gamepadInput.buttonY_pressed +
" \n X :" + gamepadInput.buttonX_pressed);
}
Input.keyboardInput(zangief, speed);

View File

@ -37,40 +37,41 @@ import static org.lwjgl.opengl.GL11.*;
*/
public class gamepadInput{
public static boolean buttonA_pressed = false;
public static boolean buttonB_pressed = false;
public static boolean buttonY_pressed = false;
public static boolean buttonX_pressed = false;
//à définir //à définir
public static void gamepadInput(ObjectGl token, int speed,int jump, int attack, int act3, int act4) { //to update for more controlBinding
public static void gamepadInput(ObjectGl token, int speed,int ButtonA, int ButtonB, int ButtonX, int ButtonY) { //to update for more controlBinding
ByteBuffer gamepadButton = glfwGetJoystickButtons(GLFW_JOYSTICK_1);
FloatBuffer gamepadAxes = glfwGetJoystickAxes(GLFW_JOYSTICK_1);
assert gamepadAxes != null;
assert gamepadButton != null;
if (gamepadButton.get(jump)==1 ) { // appuie sur croix(PlayStation) A (Xbox)
jump( token,speed);
}
if (gamepadButton.get(ButtonA)==1 ) { // appuie sur croix(PlayStation) A (Xbox)
buttonA_pressed = true;
}else buttonA_pressed = false;
if (gamepadButton.get(ButtonB)==1 ) { // appuie sur rond(PlayStation) B (Xbox)
buttonB_pressed = true;
}else buttonB_pressed = false;
if (gamepadButton.get(ButtonY)==1 ) { // appuie sur rond(PlayStation) B (Xbox)
buttonY_pressed = true;
}else buttonY_pressed = false;
if (gamepadButton.get(ButtonX)==1 ) { // appuie sur rond(PlayStation) B (Xbox)
buttonX_pressed = true;
}else buttonX_pressed = false;
if (gamepadButton.get(attack)==1 ) { // appuie sur rond(PlayStation) B (Xbox)
attack( token,speed);
}
if (gamepadAxes.get(3) > 0.1) {
crouch(token,speed);
}
}
public static void jump(ObjectGl token,int speed) {
token.translate(new Vector3f( 0.0f, speed * 20.0f, 0.0f));
}
public static void attack(ObjectGl token,int speed) {
}
public static void crouch(ObjectGl token,int speed) {
token.setTextureWrap(161,260,56,59, ObjectGl.STICK_BOTTOM);
}
}