v0.8.0: fixes/tweaks:

- damage numbers now appear where a sprite is arriving if it is moving
- blob emitters can now have a defined bound within a cell
- tweaked hero level exit/entrance behaviour
- refactored game actions that are defined in GameAction.java
This commit is contained in:
Evan Debenham
2020-01-14 16:04:51 -05:00
parent df26e32949
commit 08a719ffe2
12 changed files with 58 additions and 54 deletions

View File

@@ -52,9 +52,7 @@ public class GameAction {
}
public static final GameAction NONE = new GameAction( "none" );
public static final GameAction BACK = new GameAction( "back" );
public static final GameAction MENU = new GameAction( "menu" );
public static ArrayList<GameAction> allActions(){
return new ArrayList<>(ALL_ACTIONS);

View File

@@ -32,14 +32,6 @@ public class KeyBindings {
private static LinkedHashMap<Integer, GameAction> bindings = new LinkedHashMap<>();
public static void addKeyBinding(int keyCode, GameAction action){
bindings.put(keyCode, action);
}
public static void clearKeyBindings(){
bindings.clear();
}
public static LinkedHashMap<Integer, GameAction> getAllBindings(){
return new LinkedHashMap<>(bindings);
}
@@ -48,20 +40,32 @@ public class KeyBindings {
bindings = new LinkedHashMap<>(newBindings);
}
//these are special keybinding that are not user-configurable
private static LinkedHashMap<Integer, GameAction> hardBindings = new LinkedHashMap<>();
public static void addHardBinding(int keyCode, GameAction action){
hardBindings.put(keyCode, action);
}
public static boolean acceptUnbound = false;
public static boolean isKeyBound(int keyCode){
if (keyCode <= 0 || keyCode > 255){
return false;
}
return acceptUnbound || bindings.containsKey( keyCode );
return acceptUnbound || bindings.containsKey( keyCode ) || hardBindings.containsKey( keyCode );
}
public static GameAction getActionForKey(KeyEvent event){
return bindings.get( event.code );
if (bindings.containsKey( event.code )){
return bindings.get( event.code );
} else if (hardBindings.containsKey( event.code )) {
return hardBindings.get( event.code );
}
return GameAction.NONE;
}
public static ArrayList<Integer> getKeysForAction(GameAction action){
public static ArrayList<Integer> getBoundKeysForAction(GameAction action){
ArrayList<Integer> result = new ArrayList<>();
for( int i : bindings.keySet()){
if (bindings.get(i) == action){
@@ -76,6 +80,10 @@ public class KeyBindings {
return "None";
} else if (keyCode == Input.Keys.PLUS){
return "+";
} else if (keyCode == Input.Keys.BACKSPACE) {
return "Backspace";
} else if (keyCode == Input.Keys.FORWARD_DEL) {
return "Delete";
} else {
return Input.Keys.toString(keyCode);
}