42 lines
924 B
Java
42 lines
924 B
Java
package shootergame.input;
|
|
|
|
import static org.lwjgl.glfw.GLFW.GLFW_KEY_A;
|
|
import static org.lwjgl.glfw.GLFW.GLFW_KEY_D;
|
|
import static org.lwjgl.glfw.GLFW.GLFW_KEY_LEFT_SHIFT;
|
|
import static org.lwjgl.glfw.GLFW.GLFW_KEY_S;
|
|
import static org.lwjgl.glfw.GLFW.GLFW_KEY_SPACE;
|
|
import static org.lwjgl.glfw.GLFW.GLFW_KEY_W;
|
|
import static org.lwjgl.glfw.GLFW.GLFW_RELEASE;
|
|
|
|
import org.lwjgl.glfw.GLFWKeyCallbackI;
|
|
|
|
import shootergame.Main;
|
|
|
|
public class KeyCallback implements GLFWKeyCallbackI
|
|
{
|
|
|
|
@Override
|
|
public void invoke(long window, int key, int scancode, int action, int mods)
|
|
{
|
|
|
|
boolean pressed = ! ( action == GLFW_RELEASE );
|
|
|
|
if(key == GLFW_KEY_W) {
|
|
Main.player.MOVE_FORWARD = pressed;
|
|
}
|
|
|
|
if(key == GLFW_KEY_S) {
|
|
Main.player.MOVE_BACKWARD = pressed;
|
|
}
|
|
|
|
if(key == GLFW_KEY_A) {
|
|
Main.player.MOVE_LEFT = pressed;
|
|
}
|
|
|
|
if(key == GLFW_KEY_D) {
|
|
Main.player.MOVE_RIGHT = pressed;
|
|
}
|
|
}
|
|
|
|
}
|