aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/util/TexLoc.java
diff options
context:
space:
mode:
authorunknown <james.jenour@protonmail.com>2020-05-31 01:59:47 +1000
committerunknown <james.jenour@protonmail.com>2020-05-31 01:59:47 +1000
commitde97f55968d183cc7d76aad87e3b27d382bfdbc9 (patch)
treeeab5e7769069f31b79016e3702855ebb9f614a8e /src/main/java/io/github/moulberry/notenoughupdates/util/TexLoc.java
downloadnotenoughupdates-de97f55968d183cc7d76aad87e3b27d382bfdbc9.tar.gz
notenoughupdates-de97f55968d183cc7d76aad87e3b27d382bfdbc9.tar.bz2
notenoughupdates-de97f55968d183cc7d76aad87e3b27d382bfdbc9.zip
1.5
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/TexLoc.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/TexLoc.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/TexLoc.java b/src/main/java/io/github/moulberry/notenoughupdates/util/TexLoc.java
new file mode 100644
index 00000000..47a9c86b
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/TexLoc.java
@@ -0,0 +1,50 @@
+package io.github.moulberry.notenoughupdates.util;
+
+import org.lwjgl.input.Keyboard;
+
+public class TexLoc {
+
+ public int x;
+ public int y;
+ private int toggleKey;
+ private boolean toggled;
+ private boolean pressedLastTick;
+ private boolean dirPressed;
+
+ public TexLoc(int x, int y, int toggleKey) {
+ this.x = x;
+ this.y = y;
+ this.toggleKey = toggleKey;
+ }
+
+ public void handleKeyboardInput() {
+ if(Keyboard.isKeyDown(toggleKey)) {
+ if(!pressedLastTick) {
+ toggled = !toggled;
+ }
+ pressedLastTick = true;
+ } else {
+ pressedLastTick = false;
+ }
+ if(toggled) {
+ if(Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {
+ if(!dirPressed) x--;
+ dirPressed = true;
+ } else if(Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {
+ if(!dirPressed) x++;
+ dirPressed = true;
+ } else if(Keyboard.isKeyDown(Keyboard.KEY_UP)) {
+ if(!dirPressed) y--;
+ dirPressed = true;
+ } else if(Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {
+ if(!dirPressed) y++;
+ dirPressed = true;
+ } else {
+ dirPressed = false;
+ return;
+ }
+ System.out.println("X: " + x + " ; Y: " + y);
+ }
+ }
+
+}