generated from sigonasr2/JavaProjectTemplate
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
945 B
41 lines
945 B
package sig.engine;
|
|
|
|
import java.util.HashMap;
|
|
|
|
public class Key{
|
|
|
|
static HashMap<Integer,Boolean> KEYS = new HashMap<>();
|
|
static HashMap<Integer,Boolean> KEYS_PRESS = new HashMap<>();
|
|
static HashMap<Integer,Boolean> KEYS_RELEASE = new HashMap<>();
|
|
|
|
protected Key(int keycode) {
|
|
this.keycode=keycode;
|
|
}
|
|
int keycode;
|
|
|
|
public int getKeyCode() {
|
|
return keycode;
|
|
}
|
|
|
|
public static void setKeyHeld(int keycode,boolean pressed) {
|
|
KEYS.put(keycode,pressed);
|
|
//System.out.println(KEYS);
|
|
}
|
|
|
|
public static boolean isHeld(int keycode) {
|
|
return KEYS.getOrDefault(keycode,false);
|
|
}
|
|
|
|
public static boolean isPressed(int keycode) {
|
|
return KEYS_PRESS.getOrDefault(keycode,false);
|
|
}
|
|
|
|
public static boolean isReleased(int keycode) {
|
|
return KEYS_RELEASE.getOrDefault(keycode,false);
|
|
}
|
|
|
|
public boolean isKeyHeld() {
|
|
return KEYS.getOrDefault(keycode,false);
|
|
}
|
|
|
|
}
|
|
|