Skip to content

Commit

Permalink
gameMenu
Browse files Browse the repository at this point in the history
  • Loading branch information
PacharaphonP committed May 19, 2023
1 parent 43fdd4a commit 67914a3
Show file tree
Hide file tree
Showing 40 changed files with 389 additions and 266 deletions.
Binary file modified bin/MainMenu/GameMenu.class
Binary file not shown.
Binary file added bin/MoleDerKaiser/moleDerKaiser.png
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.
Binary file removed bin/Tiles/GrayTile.png
Binary file not shown.
Binary file removed bin/Tiles/WhiteTile.png
Binary file not shown.
Binary file removed bin/Tiles/blackStarTile.png
Binary file not shown.
Binary file removed bin/Tiles/blackTile.png
Binary file not shown.
Binary file removed bin/application/GameStart$1.class
Binary file not shown.
Binary file removed bin/application/GameStart.class
Binary file not shown.
Binary file modified bin/application/Main$1.class
Binary file not shown.
Binary file modified bin/application/Main.class
Binary file not shown.
Binary file modified bin/logic/entity/Chicknight.class
Binary file not shown.
Binary file modified bin/logic/entity/Enemy.class
Binary file not shown.
Binary file modified bin/logic/entity/EyeOfQwifot.class
Binary file not shown.
Binary file modified bin/logic/entity/GriszlyEye.class
Binary file not shown.
Binary file added bin/logic/entity/Mole.class
Binary file not shown.
Binary file added bin/logic/entity/MoleDerKaiser.class
Binary file not shown.
Binary file modified bin/logic/entity/Player.class
Binary file not shown.
Binary file modified bin/logic/entity/ShadowPot.class
Binary file not shown.
Binary file modified bin/logic/game/GameLogic.class
Binary file not shown.
Binary file modified bin/sharedObject/RenderableHolder.class
Binary file not shown.
Binary file added res/MoleDerKaiser/moleDerKaiser.png
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.
Binary file removed res/Tiles/GrayTile.png
Binary file not shown.
Binary file removed res/Tiles/WhiteTile.png
Binary file not shown.
Binary file removed res/Tiles/blackStarTile.png
Binary file not shown.
Binary file removed res/Tiles/blackTile.png
Binary file not shown.
189 changes: 96 additions & 93 deletions src/MainMenu/GameMenu.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package MainMenu;

import application.GameStart;
import application.Main;
import javafx.animation.FadeTransition;
import javafx.animation.TranslateTransition;
import javafx.scene.Parent;
Expand All @@ -10,95 +10,98 @@
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;
}
}

public GameMenu() {
GameMenu gameMenu = this;
VBox mainMenu = new VBox(10);
VBox playMenu = new VBox(10);

mainMenu.setTranslateX(1280/2.5);
mainMenu.setTranslateY(7203/4);
playMenu.setTranslateX(1280/1.5);
playMenu.setTranslateY(7203/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();
Main.isStart = true;
Main.GameStart();

gameMenu.getChildren().remove(playMenu);
gameMenu.getChildren().addAll(mainMenu);
transition(playMenu,mainMenu,640);
});

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;
}
}
71 changes: 0 additions & 71 deletions src/application/GameStart.java

This file was deleted.

Loading

0 comments on commit 67914a3

Please sign in to comment.