fix for the pom files

#story[1006]
This commit is contained in:
hba56
2017-07-14 17:07:10 +12:00
parent b7e2427528
commit 054816c15a
5 changed files with 3 additions and 77 deletions
@@ -8,6 +8,7 @@ import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import seng302.gameController.InputChecker;
public class App extends Application {
@@ -0,0 +1,49 @@
package seng302.gameController;
import javafx.animation.AnimationTimer;
import javafx.scene.Scene;
import java.util.HashMap;
/**
* Class for checking what keys are currently being used
*/
public class InputChecker {
private HashMap<String, Boolean> currentlyActiveKeys = new HashMap<>();
public void runWithScene(Scene scene){
scene.setOnKeyPressed(event -> {
String codeString = event.getCode().toString();
if (!currentlyActiveKeys.containsKey(codeString)) {
currentlyActiveKeys.put(codeString, true);
}
});
scene.setOnKeyReleased(event ->
currentlyActiveKeys.remove(event.getCode().toString())
);
new AnimationTimer() {
@Override
public void handle(long now) {
for (String key : InputKeys.listOfKeys){
if (removeActiveKey(key)) {
System.out.println(key);
}
}
}
}.start();
}
private boolean removeActiveKey(String codeString) {
Boolean isActive = currentlyActiveKeys.get(codeString);
if (isActive != null && isActive) {
currentlyActiveKeys.put(codeString, false);
return true;
} else {
return false;
}
}
}
@@ -0,0 +1,20 @@
package seng302.gameController;
import java.util.Arrays;
import java.util.List;
/**
* Class to store the basic keys used by this controller
*/
public class InputKeys {
protected static String zoomIn = "Z";
protected static String zoomOut = "X";
protected static String vmg = "SPACE";
protected static String sailsToggle = "SHIFT";
protected static String tackGybe = "Enter";
protected static String upWind = "PAGE_UP";
protected static String downWind = "Page_Down";
protected static List<String> listOfKeys = Arrays.asList(zoomIn, zoomOut, vmg,
sailsToggle, tackGybe, upWind, downWind);
}