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.
100 lines
3.4 KiB
100 lines
3.4 KiB
package seng302;
|
|
|
|
import javafx.application.Application;
|
|
import javafx.fxml.FXMLLoader;
|
|
import javafx.scene.Parent;
|
|
import javafx.scene.Scene;
|
|
import javafx.scene.layout.BorderPane;
|
|
import javafx.stage.Stage;
|
|
import seng302.Controllers.Controller;
|
|
import seng302.Controllers.MainController;
|
|
|
|
import java.io.InputStream;
|
|
import java.util.Scanner;
|
|
|
|
public class App extends Application
|
|
{
|
|
Stage primaryStage;
|
|
BorderPane mainContainer;
|
|
Scene mainScene;
|
|
|
|
public static void main( String[] args )
|
|
{
|
|
launch(args);
|
|
/* SPRINT 1 Leftovers
|
|
int timescale = 0; // Scale 5 min to 1 min, 1min = 200 5 min = 1000
|
|
|
|
Scanner sc = new Scanner(System.in);
|
|
while(timescale != 1 && timescale != 5) {
|
|
System.out.println("Enter whether you wish the race to last 1 or 5 minutes.");
|
|
String input = sc.nextLine();
|
|
try {
|
|
timescale = Integer.parseInt(input);
|
|
}catch (Exception e){
|
|
System.out.println("Please Enter a 1 or 5.");
|
|
}
|
|
}
|
|
|
|
timescale = timescale == 1 ? 200: 1000; //200ms = 1000ms if 1 minute elapse else 1000ms = 1000ms if 5 minutes
|
|
|
|
Boat[] boats = {
|
|
new Boat("ORACLE TEAM USA", 11),
|
|
new Boat("Artemis Racing", 10),
|
|
new Boat("Emirates Team New Zealand", 12),
|
|
new Boat("Groupama Team France", 11.5),
|
|
new Boat("Land Rover BAR", 11),
|
|
new Boat("SoftBank Team Japan", 10.5)
|
|
};
|
|
|
|
RaceMarker[] marks = {
|
|
new RaceMarker("Start", 0, 0, 295),
|
|
new RaceMarker("Mark", 360, 360, 250),
|
|
new RaceMarker("Leeward Gate", 965, 630, 790),
|
|
new RaceMarker("Windward Gate", 1865, 205, 0),
|
|
new RaceMarker("Leeward Gate", 2765, 630, 790),
|
|
new RaceMarker("Finish", 3035, 475, 1015)
|
|
};
|
|
|
|
Race race = new ConstantVelocityRace(boats, marks, timescale);
|
|
race.simulateRace();*/
|
|
}
|
|
|
|
@Override
|
|
public void start(Stage primaryStage) throws Exception {
|
|
this.primaryStage = primaryStage;
|
|
|
|
//load the first container
|
|
try {
|
|
FXMLLoader loader = new FXMLLoader();
|
|
InputStream in = getClass().getClassLoader().getResourceAsStream("scenes//mainpane.fxml");
|
|
mainContainer = (BorderPane) loader.load(in);
|
|
mainScene = new Scene(mainContainer, 800, 600);
|
|
primaryStage.setScene(mainScene);
|
|
primaryStage.sizeToScene();
|
|
MainController mainController = (MainController) loader.getController();
|
|
mainController.setParent(this);
|
|
in.close();
|
|
//add the center
|
|
loadPane("racepane.fxml");
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
primaryStage.show();
|
|
}
|
|
|
|
public void loadPane(String fxmlName) throws Exception{
|
|
FXMLLoader loader = new FXMLLoader();
|
|
InputStream in = getClass().getClassLoader().getResourceAsStream("scenes//"+fxmlName);
|
|
Parent page;
|
|
try {
|
|
page = (Parent) loader.load(in);
|
|
} finally {
|
|
in.close();
|
|
}
|
|
mainContainer.getChildren().remove(mainContainer.getCenter());
|
|
mainContainer.setCenter(page);
|
|
Controller controller = (Controller) loader.getController();
|
|
controller.setParent(this);
|
|
}
|
|
}
|