-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db1989d
commit a06c4c5
Showing
26 changed files
with
566 additions
and
86 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package MainMenu; | ||
|
||
import application.GameStart; | ||
import javafx.animation.FadeTransition; | ||
import javafx.animation.TranslateTransition; | ||
import javafx.scene.Parent; | ||
import javafx.scene.layout.VBox; | ||
import javafx.scene.paint.Color; | ||
import javafx.scene.shape.Rectangle; | ||
import javafx.util.Duration; | ||
|
||
public class GameMenu extends Parent{ | ||
|
||
public GameMenu() { | ||
GameMenu gameMenu = this; | ||
VBox mainMenu = new VBox(10); | ||
VBox playMenu = new VBox(10); | ||
|
||
mainMenu.setTranslateX(1280/2.5); | ||
mainMenu.setTranslateY(720*3/4); | ||
playMenu.setTranslateX(1280/1.5); | ||
playMenu.setTranslateY(720*3/4); | ||
|
||
//Main menu | ||
MenuButton startBtn = new MenuButton("START"); | ||
|
||
startBtn.setOnMouseClicked(e->{ | ||
transition(mainMenu,playMenu,-640); | ||
// gameMenu.getChildren().remove(mainMenu); | ||
gameMenu.getChildren().addAll(playMenu); | ||
}); | ||
|
||
MenuButton exitBtn = new MenuButton("QUIT"); | ||
|
||
exitBtn.setOnMouseClicked(e->{ | ||
System.exit(0); | ||
}); | ||
|
||
MenuButton optionBtn = new MenuButton("OPTION"); | ||
|
||
optionBtn.setOnMouseClicked(e->{ | ||
getChildren().add(playMenu); | ||
transition(mainMenu,playMenu,-640); | ||
|
||
}); | ||
|
||
//PlayMenu | ||
|
||
MenuButton playBtn = new MenuButton("PLAY"); | ||
|
||
playBtn.setOnMouseClicked(e->{ | ||
FadeTransition ft = new FadeTransition(Duration.seconds(0.5),this); | ||
ft.setFromValue(1); | ||
ft.setToValue(0); | ||
ft.setOnFinished(evt-> setVisible(false)); | ||
ft.play(); | ||
|
||
GameStart.start(); | ||
|
||
}); | ||
|
||
MenuButton ContBtn = new MenuButton("CONTINUE"); | ||
|
||
ContBtn.setOnMouseClicked(e->{ | ||
|
||
}); | ||
|
||
MenuButton backBtn = new MenuButton("BACK"); | ||
|
||
backBtn.setOnMouseClicked(e->{ | ||
gameMenu.getChildren().remove(playMenu); | ||
gameMenu.getChildren().addAll(mainMenu); | ||
transition(playMenu,mainMenu,640); | ||
|
||
}); | ||
|
||
|
||
Rectangle bg = new Rectangle(1280,720); | ||
bg.setOpacity(0.1); | ||
bg.setFill(Color.PINK); | ||
mainMenu.getChildren().addAll(startBtn,optionBtn,exitBtn); | ||
playMenu.getChildren().addAll(playBtn,ContBtn,backBtn); | ||
|
||
getChildren().addAll(bg,mainMenu); | ||
|
||
} | ||
|
||
public void transition(VBox menuToOut,VBox menuToin,int Xtrans) { | ||
TranslateTransition ttOut = new TranslateTransition(Duration.seconds(0.5),menuToOut); | ||
ttOut.setToX(menuToOut.getTranslateX()+Xtrans); | ||
|
||
TranslateTransition ttIn = new TranslateTransition(Duration.seconds(0.5),menuToin); | ||
ttIn.setToX(menuToOut.getTranslateX()); | ||
|
||
ttOut.play(); | ||
ttIn.play(); | ||
|
||
ttOut.setOnFinished(evt-> getGameMenu().getChildren().remove(menuToOut)); | ||
} | ||
|
||
public GameMenu getGameMenu() { | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package MainMenu; | ||
|
||
import javafx.geometry.Pos; | ||
import javafx.scene.control.Button; | ||
import javafx.scene.effect.*; | ||
import javafx.scene.layout.StackPane; | ||
import javafx.scene.paint.Color; | ||
import javafx.scene.shape.Rectangle; | ||
import javafx.scene.text.Text; | ||
|
||
public class MenuButton extends StackPane{ | ||
private Text text; | ||
|
||
public MenuButton(String name) { | ||
text = new Text(name); | ||
text.setFont(text.getFont().font(20)); | ||
|
||
Rectangle bg = new Rectangle(250,30); | ||
bg.setOpacity(0.5); | ||
bg.setFill(Color.WHITE); | ||
bg.setEffect(new Bloom(3)); | ||
|
||
setAlignment(Pos.CENTER); | ||
|
||
getChildren().addAll(text,bg); | ||
|
||
setOnMouseEntered(e->{ | ||
bg.setTranslateX(10); | ||
text.setTranslateX(10); | ||
bg.setFill(Color.LIGHTPINK); | ||
text.setFill(Color.RED); | ||
|
||
}); | ||
|
||
setOnMouseExited(e->{ | ||
bg.setTranslateX(0); | ||
text.setTranslateX(0); | ||
bg.setFill(Color.WHITE); | ||
text.setFill(Color.BLACK); | ||
}); | ||
|
||
this.setStyle("-fx-border-radius: 10;"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package application; | ||
|
||
import drawing.GameScreen; | ||
import input.InputUtility; | ||
import javafx.animation.AnimationTimer; | ||
import javafx.application.Application; | ||
import javafx.fxml.FXMLLoader; | ||
import javafx.scene.Parent; | ||
import javafx.scene.Scene; | ||
import javafx.scene.control.ProgressBar; | ||
import javafx.scene.control.ProgressIndicator; | ||
import javafx.scene.layout.StackPane; | ||
import javafx.scene.layout.VBox; | ||
import javafx.stage.Modality; | ||
import javafx.stage.Stage; | ||
import logic.game.GameLogic; | ||
import logic.entity.Player; | ||
import sharedObject.RenderableHolder; | ||
|
||
public class GameStart{ | ||
|
||
|
||
public static void start(){ | ||
final int width = 1280; | ||
final int height = 720; | ||
// VBox statBar = new VBox(); | ||
ProgressBar hpBar = new ProgressBar(); | ||
hpBar.setStyle("-fx-accent: Green; \n -fx-background-color: White; \n"); | ||
hpBar.setMaxWidth(width); | ||
hpBar.setProgress(1); | ||
ProgressBar manaBar = new ProgressBar(); | ||
manaBar.setStyle("-fx-accent: Blue; \n -fx-background-color: White; \n"); | ||
manaBar.setMaxWidth(width); | ||
manaBar.setProgress(1); | ||
|
||
Stage gameWindow = new Stage(); | ||
gameWindow.initModality(Modality.APPLICATION_MODAL); | ||
VBox root = new VBox(); | ||
Scene gameScene = new Scene(root); | ||
gameWindow.setScene(gameScene); | ||
gameWindow.setTitle("Test"); | ||
|
||
GameScreen gameScreen = new GameScreen(width, height); | ||
GameLogic logic = new GameLogic(gameScreen); | ||
root.getChildren().addAll(gameScreen,hpBar,manaBar); | ||
gameScreen.requestFocus(); | ||
|
||
|
||
AnimationTimer animation = new AnimationTimer() { | ||
long previousTime = 0; | ||
double drawInterval = 1e9/30; | ||
double delta = 0; | ||
|
||
public void handle(long now) { | ||
delta += (now-previousTime)/drawInterval; | ||
previousTime = now; | ||
|
||
if (delta >= 1) { | ||
|
||
gameScreen.paintComponent(); | ||
logic.logicUpdate(); | ||
RenderableHolder.getInstance().update(); | ||
InputUtility.updateInputState(); | ||
delta--; | ||
} | ||
} | ||
}; | ||
animation.start(); | ||
gameWindow.show(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.