added input package

test for control binding
This commit is contained in:
Léo
2021-05-30 19:06:15 +02:00
parent 4f8a32d5a4
commit 09562c4216
3 changed files with 38 additions and 26 deletions

View File

@ -1,9 +1,12 @@
package engine;
import engine.input.Input;
import engine.input.gamepadInput;
import engine.math.*;
import engine.object.*;
import engine.sound.*;
import org.lwjgl.glfw.GLFWFramebufferSizeCallback;
import org.lwjgl.glfw.GLFWVidMode;
import org.lwjgl.opengl.GL;
@ -21,7 +24,7 @@ public class Engine {
private final List<ObjectGl> objectsGl;
private static boolean present = glfwJoystickPresent(GLFW_JOYSTICK_1);
private boolean running;
@ -61,8 +64,8 @@ public class Engine {
this.setWindow(glfwCreateWindow(width, height, "Boulevard Combattant", NULL, NULL));
assert getWindow() != NULL;
System.out.println(present);
boolean present = glfwJoystickPresent(GLFW_JOYSTICK_1);
System.out.println("Manette d<>tect<63>e : " + present);
// On récupère les informations du moniteur principal
GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
@ -205,14 +208,20 @@ public class Engine {
long lastFrame;
int frame = 0;
boolean nextFrame = false;
boolean present = glfwJoystickPresent(GLFW_JOYSTICK_1);
int buttonA=0;
int buttonB=1;
int buttonX=3;
int buttonY=4;
while (engine.isRunning()) {
lastFrame = System.currentTimeMillis();
// Game logic should fit here
if (present) {
Input.gamepadInput(zangief, speed);
}
if (present) {
gamepadInput.gamepadInput(zangief, speed, buttonA, buttonB, buttonX, buttonY);
}
Input.keyboardInput(zangief, speed);
// input(smiley2, speed);

View File

@ -1,5 +1,6 @@
package engine;
package engine.input;
import engine.Engine;
import engine.math.Vector3f;
import engine.object.ObjectGl;
import org.lwjgl.glfw.GLFW;
@ -38,9 +39,7 @@ public class Input extends GLFWKeyCallback {
String name = GLFW.glfwGetJoystickName(GLFW_JOYSTICK_1);
System.out.println("GamePad Name :" + name);
// for (int i =0 ; i < gamepadAxes.capacity(); i++) {
// System.out.println(i + " :" + gamepadAxes.get(i));
// }
if (gamepadButton.get(0) ==1 ) { // appuie sur croix(PlayStation) A (Xbox)