Skip to content

Commit

Permalink
Fixed error
Browse files Browse the repository at this point in the history
  • Loading branch information
PrethamMuthappa committed Apr 17, 2024
1 parent add9541 commit c297a46
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ public void initSettings(GameSettings settings) {
settings.setSceneFactory(new SceneFactory() {
@Override
public FXGLMenu newMainMenu() {
try {
return new DinosaurMenu();
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
return new DinosaurMenu();
}

@Override
Expand Down
115 changes: 61 additions & 54 deletions src/main/java/com/dinosaur/dinosaurexploder/view/DinosaurMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

public class DinosaurMenu extends FXGLMenu {

public DinosaurMenu() throws FileNotFoundException {
public DinosaurMenu() {
super(MenuType.MAIN_MENU);

Media media = new Media(getClass().getResource(GameConstants.MAINMENU_SOUND).toExternalForm());
Expand All @@ -31,59 +31,66 @@ public DinosaurMenu() throws FileNotFoundException {
var title = FXGL.getUIFactoryService().newText(GameConstants.GAME_NAME, Color.LIME, FontType.MONO, 35);
var startButton = new Button("Start Game");
var quitButton = new Button("Quit");
FileInputStream fileInputStream= new FileInputStream("../dinosaur-exploder/src/main/resources/assets/textures/dinomenu.png");
FileInputStream mutemusic_button=new FileInputStream("../dinosaur-exploder/src/main/resources/assets/textures/silent.png");

// image for dino in main menu
Image image = new Image(fileInputStream);
ImageView imageView = new ImageView(image);
imageView.setFitHeight(250);
imageView.setFitWidth(200);
imageView.setX(200);
imageView.setY(190);
imageView.setPreserveRatio(true);

//adding image to manually mute music

Image mute = new Image(mutemusic_button);
ImageView imageView_mute=new ImageView(mute);
imageView_mute.setFitHeight(40);
imageView_mute.setFitWidth(50);
imageView_mute.setX(490);
imageView_mute.setY(20);
imageView_mute.setPreserveRatio(true);

startButton.setMinSize(50, 50);
quitButton.setMinSize(140, 50);

title.setTranslateY(100);
title.setTranslateX(getAppWidth() / 2 - 145);

startButton.setTranslateY(400);
startButton.setTranslateX(getAppWidth() / 2 - 50);
startButton.setStyle("-fx-font-size:20");

quitButton.setTranslateY(500);
quitButton.setTranslateX(getAppWidth() / 2 - 50);
quitButton.setStyle("-fx-font-size:20");

startButton.setOnAction(event -> {
fireNewGame();
mainMenuSound.stop();
});

imageView_mute.setOnMouseClicked(mouseEvent -> {
mainMenuSound.stop();
});

imageView_mute.setOnMousePressed(mouseEvent -> {
mainMenuSound.stop();
});
quitButton.setOnAction(event -> fireExit());

getContentRoot().getChildren().addAll(
bg, title, startButton, quitButton,imageView,imageView_mute
);
try {


FileInputStream fileInputStream = new FileInputStream("../dinosaur-exploder/src/main/resources/assets/textures/dinomenu.png");
FileInputStream mutemusic_button = new FileInputStream("../dinosaur-exploder/src/main/resources/assets/textures/silent.png");

// image for dino in main menu
Image image = new Image(fileInputStream);
ImageView imageView = new ImageView(image);
imageView.setFitHeight(250);
imageView.setFitWidth(200);
imageView.setX(200);
imageView.setY(190);
imageView.setPreserveRatio(true);

//adding image to manually mute music

Image mute = new Image(mutemusic_button);
ImageView imageView_mute = new ImageView(mute);
imageView_mute.setFitHeight(40);
imageView_mute.setFitWidth(50);
imageView_mute.setX(490);
imageView_mute.setY(20);
imageView_mute.setPreserveRatio(true);

startButton.setMinSize(50, 50);
quitButton.setMinSize(140, 50);

title.setTranslateY(100);
title.setTranslateX(getAppWidth() / 2 - 145);

startButton.setTranslateY(400);
startButton.setTranslateX(getAppWidth() / 2 - 50);
startButton.setStyle("-fx-font-size:20");

quitButton.setTranslateY(500);
quitButton.setTranslateX(getAppWidth() / 2 - 50);
quitButton.setStyle("-fx-font-size:20");

startButton.setOnAction(event -> {
fireNewGame();
mainMenuSound.stop();
});

imageView_mute.setOnMouseClicked(mouseEvent -> {
mainMenuSound.stop();
});

imageView_mute.setOnMousePressed(mouseEvent -> {
mainMenuSound.stop();
});
quitButton.setOnAction(event -> fireExit());

getContentRoot().getChildren().addAll(
bg, title, startButton, quitButton, imageView, imageView_mute
);
}
catch (FileNotFoundException e){
System.out.println("File not found" + e.getMessage());
}
}

}

0 comments on commit c297a46

Please sign in to comment.