Skip to content

Commit

Permalink
initial code to start a game added
Browse files Browse the repository at this point in the history
  • Loading branch information
baz committed Aug 29, 2014
1 parent 7ee2339 commit f5d1907
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions cardshifter-fx/src/main/java/com/cardshifter/fx/App.java
@@ -1,9 +1,11 @@
package com.cardshifter.fx;

//import com.cardshifter.core.Game;
import com.cardshifter.core.ConsoleController;
import com.cardshifter.core.CommandLineOptions;
import com.cardshifter.core.Game;

//import java.util.Objects;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
Expand All @@ -22,9 +24,11 @@ public App(final Game game) {
*/

@Override
public void start(Stage stage) throws Exception {
public void start(Stage stage) throws Exception {
//stage.setTitle("title");

this.startGame();

Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));

Scene scene = new Scene(root);
Expand All @@ -33,12 +37,18 @@ public void start(Stage stage) throws Exception {
//stage.centerOnScreen();
stage.show();
}


// @param args the command line arguments

public static void main(String[] args) {
launch(args);
}

public void startGame() throws Exception {
CommandLineOptions options = new CommandLineOptions();
InputStream file = options.getScript() == null ? Game.class.getResourceAsStream("start.lua") : new FileInputStream(new File(options.getScript()));
Game game = new Game(file, options.getRandom());
game.getEvents().startGame(game);
}

}

0 comments on commit f5d1907

Please sign in to comment.