De la doc pour les classe dans UIElement, gestion du clavier dans la classe Button.

This commit is contained in:
Antoine
2021-06-05 02:02:14 +02:00
parent 9ebf04338e
commit d11a1fa293
5 changed files with 34 additions and 34 deletions

View File

@@ -1,22 +1,30 @@
package engine.input;
import engine.Engine;
import java.util.List;
import static org.lwjgl.glfw.GLFW.glfwGetKey;
public class Button {
public String name;
private final List<Integer> buttons;
private final List<Integer> buttonsGamepad;
private final List<Integer> buttonsKeyboard;
private final GamepadInput controller;
public Button(String name, List<Integer> buttons, GamepadInput controller){
public Button(String name, List<Integer> buttonsGamepad, List<Integer> buttonsKeyboard, GamepadInput controller){
this.name = name;
this.buttons = buttons;
this.buttonsGamepad = buttonsGamepad;
this.buttonsKeyboard = buttonsKeyboard;
this.controller = controller;
}
public boolean isButtonPressed(){
for (int i : buttons){
for (int i : buttonsGamepad){
if (controller.checkPressed(i)) return true;
} for (int i : buttonsKeyboard){
if (glfwGetKey(Engine.getWindow(), i) == 1) return true;
}
return false;
}