parent
93c1199392
commit
6ae23f039b
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>team-7</artifactId>
|
||||
<groupId>seng302</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>1</artifactId>
|
||||
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,7 @@
|
||||
package seng302.Controllers;
|
||||
|
||||
/**
|
||||
* Controller for the main window fxml of the Game Controller
|
||||
*/
|
||||
public class MainWindowController {
|
||||
}
|
||||
@ -0,0 +1,101 @@
|
||||
package seng302;
|
||||
|
||||
import javafx.animation.AnimationTimer;
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Entry point for the controller side of the application
|
||||
*/
|
||||
public class Main extends Application {
|
||||
//holds a boolean state for each important key to show if pressed down or not
|
||||
private HashMap<String, Boolean> currentlyActiveKeys = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Entry point for running the programme
|
||||
*
|
||||
* @param args for starting the programme
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage stage) {
|
||||
try {
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getClassLoader().getResource("mainWindow.fxml"));
|
||||
Parent root = loader.load();
|
||||
|
||||
Scene scene = new Scene(root, 200, 100);
|
||||
stage.setScene(scene);
|
||||
stage.setTitle("Controller");
|
||||
|
||||
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) {
|
||||
if (removeActiveKey("Z")) {
|
||||
System.out.println("zoom in");
|
||||
}
|
||||
|
||||
if (removeActiveKey("X")) {
|
||||
System.out.println("zoom out");
|
||||
}
|
||||
|
||||
if (removeActiveKey("SPACE")) {
|
||||
System.out.println("VMG");
|
||||
}
|
||||
|
||||
if (removeActiveKey("SHIFT")) {
|
||||
System.out.println("sails in/out");
|
||||
}
|
||||
|
||||
if (removeActiveKey("Enter")) {
|
||||
System.out.println("tack/gybe");
|
||||
}
|
||||
|
||||
if (removeActiveKey("PAGE_UP")) {
|
||||
System.out.println("up wind");
|
||||
}
|
||||
|
||||
if (removeActiveKey("PAGE_DOWN")) {
|
||||
System.out.println("down wind");
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
|
||||
stage.show();
|
||||
} catch (IOException e) {
|
||||
//Catch all exceptions, print, and exit.
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
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,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.layout.BorderPane?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
|
||||
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="100.0" prefWidth="200.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.MainWindowController">
|
||||
<center>
|
||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Controller Is running" BorderPane.alignment="CENTER" />
|
||||
</center>
|
||||
</BorderPane>
|
||||
Loading…
Reference in new issue