Advertisement
Guest User

Untitled

a guest
Apr 8th, 2024
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.42 KB | Source Code | 0 0
  1.  
  2. import javafx.application.Application;
  3. import javafx.geometry.Insets;
  4. import javafx.geometry.Pos;
  5. import javafx.scene.Group;
  6. import javafx.scene.Scene;
  7. import javafx.scene.control.Button;
  8. import javafx.scene.control.Label;
  9. import javafx.scene.control.TextField;
  10. import javafx.scene.layout.Background;
  11. import javafx.scene.layout.GridPane;
  12. import javafx.scene.layout.HBox;
  13. import javafx.scene.layout.VBox;
  14. import javafx.scene.text.Font;
  15. import javafx.stage.Stage;
  16.  
  17. public class opening extends Application {
  18. // first scene (buttons
  19. Label gameTitle = new Label("Basil's Cat Game :3");
  20.  
  21. // new game buttons
  22. TextField putNameHere = new TextField();
  23.  
  24. Label putNameTxt = new Label("Name:");
  25. Button nameOkButton = new Button("OK");
  26.  
  27. VBox titleVBox = new VBox();
  28. HBox titleHBox = new HBox();
  29. GridPane titleGroup = new GridPane();
  30. Button backBtn = new Button("BACK");
  31.  
  32. VBox title = new VBox();
  33. Button exitBtn = new Button();
  34.  
  35. Group titleGroupSec = new Group();
  36.  
  37. boolean buttonClicked = false;
  38.  
  39. @Override
  40. public void start(Stage primaryStage) throws Exception {
  41. // needs buttons to select what to do and also a text field to store a name
  42. gameTitle.setFont(Font.font(STYLESHEET_CASPIAN, 40));
  43.  
  44. Button playBtn = new Button("NEW");
  45. playBtn.setFont(Font.font(30));
  46. playBtn.setBackground(Background.EMPTY);
  47. Button loadBtn = new Button("LOAD");
  48. loadBtn.setFont(Font.font(30));
  49. loadBtn.setBackground(Background.EMPTY);
  50. Button exitBtn = new Button("EXIT");
  51. exitBtn.setFont(Font.font(30));
  52. exitBtn.setBackground(Background.EMPTY);
  53.  
  54. Button exitBtnSec = new Button("EXIT");
  55. exitBtnSec.setFont(Font.font(30));
  56. exitBtnSec.setBackground(Background.EMPTY);
  57.  
  58. VBox btnVBox = new VBox();
  59. btnVBox.getChildren().add(0, gameTitle);
  60. btnVBox.getChildren().add(1, playBtn);
  61. btnVBox.getChildren().add(2, loadBtn);
  62. btnVBox.getChildren().add(3, exitBtn);
  63. btnVBox.setAlignment(Pos.TOP_CENTER);
  64. btnVBox.setSpacing(20);
  65.  
  66. titleGroup.getChildren().remove(titleHBox);
  67. titleGroup.getChildren().remove(titleVBox);
  68. titleGroup.getChildren().addLast(btnVBox);
  69. titleGroup.setAlignment(Pos.TOP_CENTER);
  70. titleGroup.setPadding(new Insets(50));
  71.  
  72. /**
  73. * maybe should change to say "NEW"? anyways, make them pick a name (move name
  74. * feature to here & show a quick text based tutorial that does some waiting
  75. * liek im sayin it to the player :3
  76. *
  77. * make them roll for a cat nd name the cat. save the cat and it's features to a
  78. * file that is specific to this player.
  79. *
  80. * make it so they can access a list to see player info (name) and cat info(how
  81. * many cats, names, breeds, traits, colors)
  82. */
  83. playBtn.setOnMouseClicked(playBtnClickedEvent -> {
  84. btnVBox.getChildren().remove(loadBtn);
  85. btnVBox.getChildren().remove(exitBtn);
  86. btnVBox.getChildren().remove(playBtn);
  87.  
  88.  
  89.  
  90. exitBtn.setAlignment(Pos.TOP_LEFT);
  91.  
  92. gameTitle.setFont(Font.font(STYLESHEET_CASPIAN, 40));
  93.  
  94. putNameTxt.setFont(Font.font(STYLESHEET_CASPIAN, 20));
  95.  
  96. putNameHere.setEditable(true);
  97.  
  98. nameOkButton.setFont(Font.font(10));
  99.  
  100. title.getChildren().add(putNameTxt);
  101. title.getChildren().addLast(exitBtn);
  102. title.getChildren().addFirst(gameTitle);
  103.  
  104. title.setSpacing(10);
  105. title.setAlignment(Pos.TOP_CENTER);
  106.  
  107. titleHBox.getChildren().addFirst(putNameHere);
  108. titleHBox.getChildren().addLast(nameOkButton);
  109. titleHBox.setPadding(new Insets(100));
  110. titleHBox.setAlignment(Pos.CENTER);
  111.  
  112. titleGroup.getChildren().addFirst(backBtn);
  113. titleGroup.getChildren().add(title);
  114. titleGroup.getChildren().addLast(titleHBox);
  115.  
  116.  
  117.  
  118. });
  119.  
  120. /**
  121. * here, u will probably have to implement something more complex than a file
  122. * writer if you decide to use photos or graphics to make ur kitties :P
  123. *
  124. * call the names of players (only players that have pressed the PLAY button &
  125. * gotten a cat.. show the amt of cats they have next to their name :P)
  126. *
  127. * if they click on the button that has their name/amt of cats then make open
  128. * that save file in the stage
  129. */
  130. loadBtn.setOnMouseClicked(loadBtnClickedEvent -> {
  131.  
  132. });
  133.  
  134. exitBtn.setOnMouseClicked(exitBtnClickedEvent -> {
  135. primaryStage.close();
  136. });
  137.  
  138. Scene scene = new Scene(titleGroup, 500, 500);
  139. primaryStage.setScene(scene);
  140. primaryStage.setTitle("love u <3");
  141. primaryStage.show();
  142.  
  143. }
  144.  
  145. public static void main(String[] args) {
  146. launch(args);
  147. }
  148. }
  149.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement