diff options
Diffstat (limited to '')
| -rw-r--r-- | src/gui/Block.java (renamed from src/main/Block.java) | 12 | ||||
| -rw-r--r-- | src/gui/Driver.java | 19 | ||||
| -rw-r--r-- | src/gui/Leaderboard.java | 45 | ||||
| -rw-r--r-- | src/gui/Level.java | 110 | ||||
| -rw-r--r-- | src/gui/LevelSelector.java | 26 | ||||
| -rw-r--r-- | src/gui/MainMenu.java | 68 | ||||
| -rw-r--r-- | src/gui/Settings.java | 68 | ||||
| -rw-r--r-- | src/gui/application.css (renamed from src/main/application.css) | 0 | 
8 files changed, 342 insertions, 6 deletions
diff --git a/src/main/Block.java b/src/gui/Block.java index 8f8267f..42cedba 100644 --- a/src/main/Block.java +++ b/src/gui/Block.java @@ -1,6 +1,6 @@  //glowing block of color c (jfx node) -package main; +package gui;  import javafx.scene.effect.BlurType;  import javafx.scene.effect.DropShadow; @@ -9,7 +9,7 @@ import javafx.scene.shape.Rectangle;  public class Block extends Rectangle  { -    public Block(Color c) +    public Block(Color c, double a, double b, int r)      {          super();          DropShadow dropShadow = new DropShadow(); @@ -18,10 +18,10 @@ public class Block extends Rectangle          dropShadow.setBlurType(BlurType.GAUSSIAN);          super.setFill(c); -        super.setWidth(200); -        super.setHeight(100); -        super.setArcHeight(25); -        super.setArcWidth(25); +        super.setWidth(a); +        super.setHeight(b); +        super.setArcHeight(r); +        super.setArcWidth(r);          super.setEffect(dropShadow);      }  }
\ No newline at end of file diff --git a/src/gui/Driver.java b/src/gui/Driver.java new file mode 100644 index 0000000..a01498e --- /dev/null +++ b/src/gui/Driver.java @@ -0,0 +1,19 @@ +package gui; + +import javafx.application.Application; +import javafx.stage.Stage; + +public class Driver extends Application  +{ +    public static void main(String[] args)  +    { +        launch(args); +    } +     +    @Override +    public void start(Stage primaryStage)  +    { +        primaryStage.setScene(new MainMenu(primaryStage)); +        primaryStage.show(); +    } +} diff --git a/src/gui/Leaderboard.java b/src/gui/Leaderboard.java new file mode 100644 index 0000000..e9268bc --- /dev/null +++ b/src/gui/Leaderboard.java @@ -0,0 +1,45 @@ +package gui; + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.geometry.Pos; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.ListView; +import javafx.scene.layout.Pane; +import javafx.scene.layout.VBox; +import javafx.stage.Stage; + +public class Leaderboard extends Scene +{ +    private static Pane root = new Pane(); +    public Leaderboard(Stage primaryStage) +    { +        super(root,800,600); +        primaryStage.setTitle("NPE Hero - Leaderboard"); + +        ListView<String> scores = new ListView<String>(); +        ObservableList<String> scoreList= FXCollections.observableArrayList ("Test Score 1", "Test Score 2", "Test Score 3", "Test Score 4"); +        scores.setItems(scoreList); + +        Button exit = new Button(); +        exit.setText("Exit"); +        exit.setOnAction(new EventHandler<ActionEvent>()  +        { +            @Override +            public void handle(ActionEvent event)  +            { +                primaryStage.setScene(new MainMenu(primaryStage)); +            } +        }); +         +        VBox centerMenu3 = new VBox(); +        centerMenu3.minWidthProperty().bind(primaryStage.widthProperty());  +        centerMenu3.minHeightProperty().bind(primaryStage.heightProperty()); +        centerMenu3.setAlignment(Pos.CENTER); +        centerMenu3.getChildren().addAll(scores,exit); +        root.getChildren().add(centerMenu3); +    } +} diff --git a/src/gui/Level.java b/src/gui/Level.java new file mode 100644 index 0000000..993b631 --- /dev/null +++ b/src/gui/Level.java @@ -0,0 +1,110 @@ +package gui; + +import javafx.application.Application; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.geometry.Insets; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.effect.BlurType; +import javafx.scene.effect.DropShadow; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.Background; +import javafx.scene.layout.BackgroundFill; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.CornerRadii; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.Pane; +import javafx.scene.layout.StackPane; +import javafx.scene.paint.Color; +import javafx.scene.shape.Rectangle; +import javafx.scene.text.Font; +import javafx.scene.text.FontWeight; +import javafx.scene.text.Text; +import javafx.stage.Stage; +  +public class Level extends Application { +    public static void main(String[] args) { +        launch(args); +    } +     +    @Override +    public void start(Stage primaryStage) { +        primaryStage.setTitle("program"); + +        BorderPane background = new BorderPane(); +        Scene game = new Scene(background, 800, 600); +        GridPane blockGrid = new GridPane(); +        blockGrid.setBackground(new Background(new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY))); +        background.setCenter(blockGrid); +         +        blockGrid.maxWidthProperty().bind(game.heightProperty().multiply(0.53)); +        blockGrid.maxHeightProperty().bind(game.heightProperty()); +        System.out.println(game.heightProperty()); +         +        //blockGrid.setMaxHeight(700); +        //blockGrid.setMaxWidth(500); +        //blockGrid.setScaleX(1); +        //blockGrid.setScaleY(1); +        //blockGrid.scaleXProperty().bind(game.heightProperty().divide(1000)); +        //blockGrid.scaleYProperty().bind(game.heightProperty().divide(1000)); +        //blockGrid.hgapProperty().bind(blockGrid.heightProperty().divide(11)); +        //blockGrid.vgapProperty().bind(blockGrid.widthProperty().divide(21)); +        blockGrid.setVgap(10); +        blockGrid.setHgap(25); + +        int blocksize = 50; +        //AnchorPane b11 = new AnchorPane(); +        //b11.getChildren().add(new Block(Color.ORANGE, b11, 10)); +        Block b1 = new Block(Color.RED, blocksize, blocksize, 10); +        //b1.heightProperty().bind(blockGrid.heightProperty().divide((blockGrid.getColumnCount()*2)+1)); +        //b1.widthProperty().bind(blockGrid.widthProperty().divide((blockGrid.getRowCount()*2)+1)); + +        Block b2 = new Block(Color.BLUE, blocksize, blocksize, 10); +        //b2.heightProperty().bind(blockGrid.heightProperty().divide(21)); +        //b2.widthProperty().bind(blockGrid.widthProperty().divide(11)); + +        Block b3 = new Block(Color.GREEN, blocksize, blocksize, 10); +        //b3.heightProperty().bind(blockGrid.heightProperty().divide(21)); +        //b3.widthProperty().bind(blockGrid.widthProperty().divide(11)); + +        Block b4 = new Block(Color.YELLOW, blocksize, blocksize, 10); +        //b4.heightProperty().bind(blockGrid.heightProperty().divide(21)); +        //b4.widthProperty().bind(blockGrid.widthProperty().divide(11)); + +        Pane test = new Pane(); + +        Block b5 = new Block(Color.ORANGE, blocksize, blocksize, 10); +        DropShadow dropShadow = new DropShadow(); +        dropShadow.setRadius(200.0); +        dropShadow.setColor(Color.ORANGE); +        dropShadow.setBlurType(BlurType.GAUSSIAN); +        test.getChildren().add(b5); +        test.setEffect(dropShadow); + +        + +        blockGrid.add(b1, 0, 0); +        blockGrid.add(b2, 1, 0); +        blockGrid.add(b3, 0, 1); +        blockGrid.add(b4, 1, 1); +        blockGrid.add(test, 1, 2); + +        Button btn = new Button(); +        btn.setText("Test"); +        btn.setOnAction(new EventHandler<ActionEvent>()  +        { +            @Override +            public void handle(ActionEvent event)  +            { +                System.out.println("test"); +            } +        }); + +        background.setLeft(btn); + +        primaryStage.setScene(game); +        primaryStage.show(); +         +    } +}
\ No newline at end of file diff --git a/src/gui/LevelSelector.java b/src/gui/LevelSelector.java new file mode 100644 index 0000000..25d1ed2 --- /dev/null +++ b/src/gui/LevelSelector.java @@ -0,0 +1,26 @@ +package gui; + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.geometry.Pos; +import javafx.scene.Scene; +import javafx.scene.control.ListView; +import javafx.scene.layout.VBox; +import javafx.stage.Stage; + +public class LevelSelector extends Scene +{ +    private static VBox centerMenu2 = new VBox(); +     +    public LevelSelector(Stage primaryStage) +    { +        super(centerMenu2,800,600); +        primaryStage.setTitle("NPE Hero - Level Selector"); +        ListView<String> levels = new ListView<String>(); +        ObservableList<String> levelList= FXCollections.observableArrayList ("Test Level 1", "Test Level 2", "Test Level 3", "Test Level 4"); +        levels.setItems(levelList); +        centerMenu2.setAlignment(Pos.CENTER); +        centerMenu2.getChildren().add(levels); +    } + +} diff --git a/src/gui/MainMenu.java b/src/gui/MainMenu.java new file mode 100644 index 0000000..0c7ab7f --- /dev/null +++ b/src/gui/MainMenu.java @@ -0,0 +1,68 @@ +package gui; + +import javafx.event.EventHandler; +import javafx.event.ActionEvent; +import javafx.geometry.Pos; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.layout.Pane; +import javafx.scene.layout.VBox; +import javafx.scene.text.Font; +import javafx.scene.text.Text; +import javafx.stage.Stage; + +public class MainMenu extends Scene +{ +    private static Pane root = new Pane(); +    public MainMenu(Stage primaryStage) +    { +        super(root,800,600); +        primaryStage.setTitle("NPE Hero - Main menu"); + +        Text title = new Text(); +        title.setText("NPE Hero"); +        title.setFont(new Font(48)); +        //set color + +        Button play = new Button(); +        play.setText("Play"); +        play.setOnAction(new EventHandler<ActionEvent>()  +        { +            @Override +            public void handle(ActionEvent event)  +            { +                primaryStage.setScene(new LevelSelector(primaryStage)); +            } +        }); + +        Button settings = new Button(); +        settings.setText("Settings"); +        settings.setOnAction(new EventHandler<ActionEvent>()  +        { +            @Override +            public void handle(ActionEvent event)  +            { +                primaryStage.setScene(new Settings(primaryStage)); +            } +        }); + +        Button leaderboard = new Button(); +        leaderboard.setText("Leaderboard"); +        leaderboard.setOnAction(new EventHandler<ActionEvent>()  +        { +            @Override +            public void handle(ActionEvent event)  +            { +                primaryStage.setScene(new Leaderboard(primaryStage)); +            } +        }); + +        VBox centerMenu = new VBox(); +        centerMenu.getChildren().addAll(title, play, settings, leaderboard); +        centerMenu.minWidthProperty().bind(primaryStage.widthProperty());  +        centerMenu.minHeightProperty().bind(primaryStage.heightProperty()); +        centerMenu.setAlignment(Pos.CENTER); + +        root.getChildren().add(centerMenu); +    } +} diff --git a/src/gui/Settings.java b/src/gui/Settings.java new file mode 100644 index 0000000..1b50fe5 --- /dev/null +++ b/src/gui/Settings.java @@ -0,0 +1,68 @@ +package gui; + +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.geometry.Pos; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.Slider; +import javafx.scene.layout.Pane; +import javafx.scene.layout.VBox; +import javafx.scene.text.Text; +import javafx.stage.Stage; + +public class Settings extends Scene +{ +    private static Pane primaryPane = new Pane(); + +    public Settings(Stage primaryStage) +    { +        super(primaryPane, 800, 600); +        primaryStage.setTitle("NPE Hero - Main menu"); +        Scene root = super.getRoot().getScene(); + +        Text t1 = new Text(); +        t1.setText("Music Volume"); + +        Slider musicVol = new Slider(); +        musicVol.setMax(100); +        musicVol.setMin(0); + +        Text t2 = new Text(); +        t2.setText("Sound Effects Volume"); + +        Slider sfxVol = new Slider(); +        sfxVol.setMax(100); +        sfxVol.setMin(0); + +        Button devMenu = new Button(); +        devMenu.setText("Debug Menu"); +        devMenu.setOnAction(new EventHandler<ActionEvent>()  +        { +            @Override +            public void handle(ActionEvent event)  +            { +                System.out.println("not yet implimented"); +            } +        }); + +        Button exit = new Button(); +        exit.setText("Exit"); +        exit.setOnAction(new EventHandler<ActionEvent>()  +        { +            @Override +            public void handle(ActionEvent event)  +            { +                primaryStage.setScene(root); +            } +        }); + +        VBox options = new VBox(); +        options.setAlignment(Pos.CENTER); +        options.getChildren().addAll(t1,musicVol,t2,sfxVol,devMenu,exit); +        options.minWidthProperty().bind(primaryStage.widthProperty());  +        options.minHeightProperty().bind(primaryStage.heightProperty()); +        primaryPane.getChildren().add(options); +    } +     +} diff --git a/src/main/application.css b/src/gui/application.css index e69de29..e69de29 100644 --- a/src/main/application.css +++ b/src/gui/application.css  | 
