Oune poquito de docito
+ Rename de certaine classe pour qu'elles respectent les conventions
This commit is contained in:
parent
62b888da92
commit
cf7a1ed85b
@ -1,7 +1,6 @@
|
||||
package engine;
|
||||
|
||||
import engine.input.Input;
|
||||
//import engine.input.gamepadInput;
|
||||
import engine.input.KeyboardInput;
|
||||
import engine.input.GamepadInput;
|
||||
import engine.math.*;
|
||||
import engine.object.*;
|
||||
@ -73,7 +72,7 @@ public class Engine {
|
||||
// On met la fenêtre au centre de l'écran principale
|
||||
glfwSetWindowPos(getWindow(), (vidmode.width() - width) / 2, (vidmode.height() - height) / 2);
|
||||
|
||||
glfwSetKeyCallback(getWindow(), new Input());
|
||||
glfwSetKeyCallback(getWindow(), new KeyboardInput());
|
||||
glfwSetInputMode(getWindow(), GLFW_STICKY_KEYS, GLFW_TRUE);
|
||||
|
||||
// Contexte = zone cible des rendus
|
||||
|
@ -5,7 +5,7 @@ import engine.math.Vector3f;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
import static engine.input.inputConst.*;
|
||||
import static engine.input.InputConst.*;
|
||||
import static org.lwjgl.glfw.GLFW.*;
|
||||
/* Buttons
|
||||
0 : Croix / A
|
||||
@ -36,6 +36,8 @@ import static org.lwjgl.glfw.GLFW.*;
|
||||
public class GamepadInput {
|
||||
|
||||
private final int gamepadNum;
|
||||
private ByteBuffer gamepadButton;
|
||||
private FloatBuffer gamepadAxes;
|
||||
|
||||
public boolean buttonA_pressed ;
|
||||
public boolean buttonB_pressed ;
|
||||
@ -97,9 +99,10 @@ public class GamepadInput {
|
||||
this.RT_pressed = false;
|
||||
}
|
||||
|
||||
public void inputRefresh() {
|
||||
ByteBuffer gamepadButton = glfwGetJoystickButtons(this.gamepadNum);
|
||||
FloatBuffer gamepadAxes = glfwGetJoystickAxes(this.gamepadNum);
|
||||
public void inputRefresh() {
|
||||
|
||||
this.gamepadButton = glfwGetJoystickButtons(this.gamepadNum);
|
||||
this.gamepadAxes = glfwGetJoystickAxes(this.gamepadNum);
|
||||
|
||||
assert gamepadAxes != null;
|
||||
assert gamepadButton != null;
|
||||
@ -153,7 +156,7 @@ public class GamepadInput {
|
||||
}
|
||||
|
||||
public boolean checkPressed(int keyCode){
|
||||
ByteBuffer gamepadButton = glfwGetJoystickButtons(GLFW_JOYSTICK_1);
|
||||
this.gamepadButton = glfwGetJoystickButtons(GLFW_JOYSTICK_1);
|
||||
|
||||
assert gamepadButton != null;
|
||||
|
||||
@ -161,16 +164,12 @@ public class GamepadInput {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param axisId
|
||||
* @return
|
||||
* Envoie la position du stick pointé par axisId sous forme de direction général (9 directions)
|
||||
* @param axisId l'identifiant du joystick (AXE X)
|
||||
* @return la direction du stick valeur possible : RIGHT, UPPER_RIGHT, UP, UPPER_LEFT, LEFT, LOWER_LEFT, DOWN, LOWER_RIGHT, CENTER;
|
||||
*/
|
||||
public int getAxisDiscreet(int axisId){
|
||||
|
||||
FloatBuffer gamepadAxes = glfwGetJoystickAxes(GLFW_JOYSTICK_1);
|
||||
|
||||
assert gamepadAxes != null;
|
||||
|
||||
float x = gamepadAxes.get(axisId);
|
||||
float y = gamepadAxes.get(axisId + 1);
|
||||
|
||||
@ -191,16 +190,12 @@ public class GamepadInput {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Envoie la position du stick pointé par axisID (AXE X) sous forme de Vecteur
|
||||
* @param axisId l'identifiant du joystick (AXE X)
|
||||
* @return un Vecteur représentant la position actuel du joystick
|
||||
*/
|
||||
public Vector3f getAxisContinuous(int axisId){
|
||||
|
||||
FloatBuffer gamepadAxes = glfwGetJoystickAxes(GLFW_JOYSTICK_1);
|
||||
|
||||
assert gamepadAxes != null;
|
||||
|
||||
float x = gamepadAxes.get(axisId);
|
||||
float y = gamepadAxes.get(axisId + 1);
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package engine.input;
|
||||
|
||||
public class inputConst {
|
||||
public class InputConst {
|
||||
/*
|
||||
Button ID
|
||||
*/
|
@ -12,7 +12,7 @@ import java.nio.FloatBuffer;
|
||||
import static org.lwjgl.glfw.GLFW.*;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
public class Input extends GLFWKeyCallback {
|
||||
public class KeyboardInput extends GLFWKeyCallback {
|
||||
|
||||
public static boolean[] keys = new boolean[65536];
|
||||
|
||||
@ -89,18 +89,18 @@ public class Input extends GLFWKeyCallback {
|
||||
|
||||
public static void keyboardInput(ObjectGl token, int speed) {
|
||||
boolean keyPressed = false;
|
||||
if (Input.isKeyDown(GLFW.GLFW_KEY_S)) {
|
||||
if (KeyboardInput.isKeyDown(GLFW.GLFW_KEY_S)) {
|
||||
token.setTextureWrap(161,260,56,59, ObjectGl.STICK_BOTTOM);
|
||||
keyPressed = true;
|
||||
} else if (Input.isKeyDown(GLFW.GLFW_KEY_W)) {
|
||||
} else if (KeyboardInput.isKeyDown(GLFW.GLFW_KEY_W)) {
|
||||
keyPressed = true;
|
||||
}
|
||||
if (Input.isKeyDown(GLFW.GLFW_KEY_A)) {
|
||||
if (KeyboardInput.isKeyDown(GLFW.GLFW_KEY_A)) {
|
||||
token.translate(new Vector3f (speed * -5.0f, 0.0f, 0.0f));
|
||||
token.setTextureWrap(121,0,57,82, ObjectGl.STICK_TOP);
|
||||
keyPressed = true;
|
||||
}
|
||||
else if (Input.isKeyDown(GLFW.GLFW_KEY_D)) {
|
||||
else if (KeyboardInput.isKeyDown(GLFW.GLFW_KEY_D)) {
|
||||
token.translate(new Vector3f (speed * 5.0f, 0.0f, 0.0f));
|
||||
token.setTextureWrap(178,0,62,82, ObjectGl.STICK_TOP);
|
||||
keyPressed = true;
|
Loading…
x
Reference in New Issue
Block a user