initial commit
This commit is contained in:
parent
3c9ee26b06
commit
22186c33b9
1458 changed files with 282792 additions and 0 deletions
49
java/src/game/Button.java
Normal file
49
java/src/game/Button.java
Normal file
|
@ -0,0 +1,49 @@
|
|||
package game;
|
||||
|
||||
public enum Button implements Input {
|
||||
MOUSE_LEFT("lmb", "Linke Maustaste"),
|
||||
MOUSE_RIGHT("rmb", "Rechte Maustaste"),
|
||||
MOUSE_MIDDLE("mmb", "Mittlere Maustaste"),
|
||||
MOUSE_BTN_X("xmb", "Maustaste Seite 1"),
|
||||
MOUSE_BTN_Y("ymb", "Maustaste Seite 2"),
|
||||
MOUSE_BTN_A("m6", "Maustaste 6"),
|
||||
MOUSE_BTN_B("m7", "Maustaste 7"),
|
||||
MOUSE_BTN_C("m8", "Maustaste 8");
|
||||
|
||||
private static int buttons;
|
||||
|
||||
private final String id;
|
||||
private final String name;
|
||||
|
||||
private boolean down;
|
||||
|
||||
public static boolean isMouseDown() {
|
||||
return buttons != 0;
|
||||
}
|
||||
|
||||
private Button(String id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getDisplay() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public boolean read() {
|
||||
return Game.getGame().open == null && this.down;
|
||||
}
|
||||
|
||||
public void setDown(boolean down) {
|
||||
this.down = down;
|
||||
buttons = (buttons & ~(1 << this.ordinal())) | (down ? 1 << this.ordinal() : 0);
|
||||
}
|
||||
|
||||
public boolean isDown() {
|
||||
return this.down;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue