Skip to content

Commit

Permalink
help kind of done
Browse files Browse the repository at this point in the history
  • Loading branch information
Glowstick0017 committed Nov 13, 2021
1 parent 0411c23 commit 6a4aa45
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 22 deletions.
10 changes: 8 additions & 2 deletions src/main/java/com/example/conway/ConwayController.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,13 @@ public void helpClicked(ActionEvent event) throws IOException {
Stage stage = new Stage();
stage.setScene(new Scene(fxmlLoader.load()));
HelpController hc = fxmlLoader.getController();
hc.textArea.setText("The Game of Life is not your typical computer game. It is a cellular automaton, and was invented by Cambridge mathematician John Conway.\n\n" +
"This game became widely known when it was mentioned in an article published by Scientific American in 1970. It consists of a collection of cells which, based on a few mathematical rules, can live, die or multiply. Depending on the initial conditions, the cells form various patterns throughout the course of the game.");
hc.aboutText.setText("The Game of Life is not your typical computer game. It is a cellular automaton, and was invented by Cambridge mathematician John Conway.\n\n" +
"This game became widely known when it was mentioned in an article published by Scientific American in 1970. It consists of a collection of cells which, " +
"based on a few mathematical rules, can live, die or multiply. Depending on the initial conditions, the cells form various patterns throughout the course of the game.");
hc.rulesText.setText("Each cell with one or no neighbors dies, as if by solitude.\n\n\n" +
"Each cell with four or more neighbors dies, as if by overpopulation.\n\n\n" +
"Each cell with two or three neighbors survives.\n\n\n\n\n" +
"Each cell with three neighbors becomes populated.");
stage.setAlwaysOnTop(true);
stage.getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon.png"))));
stage.show();
Expand All @@ -99,6 +104,7 @@ public void setLife(Life life) {
}

public void resetClicked(ActionEvent event) {
startStop.setText("Start");
life.reset(startStop.getScene());
}
}
41 changes: 40 additions & 1 deletion src/main/java/com/example/conway/HelpController.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,51 @@
package com.example.conway;

import javafx.event.ActionEvent;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.MenuButton;
import javafx.scene.control.ScrollPane;
import javafx.scene.input.MouseEvent;
import javafx.scene.text.Text;

public class HelpController {
public Text textArea;
public Text aboutText;
public Text rulesText;
public Text controlsText;
public ScrollPane aboutPane;
public ScrollPane rulesPane;
public ScrollPane controlPane;
public MenuButton menuButton;
public Hyperlink lexiconLink;

public void glowstickClicked(ActionEvent event) {
Main.getHS().showDocument("https://github.com/glowstick0017");
}

public void onAboutClick(ActionEvent event) {
menuButton.setText("About");
aboutPane.setVisible(true);
rulesPane.setVisible(false);
controlPane.setVisible(false);
lexiconLink.setVisible(false);
}

public void onRulesClick(ActionEvent event) {
menuButton.setText("Rules");
aboutPane.setVisible(false);
rulesPane.setVisible(true);
controlPane.setVisible(false);
lexiconLink.setVisible(false);
}

public void onControlsClick(ActionEvent event) {
menuButton.setText("Controls");
aboutPane.setVisible(false);
rulesPane.setVisible(false);
controlPane.setVisible(true);
lexiconLink.setVisible(true);
}

public void lexiconClick(MouseEvent mouseEvent) {
Main.getHS().showDocument("https://bitstorm.org/gameoflife/lexicon/");
}
}
Binary file added src/main/resources/com/example/conway/born.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 10 additions & 8 deletions src/main/resources/com/example/conway/conway.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.text.Font?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="382.0"
prefWidth="600.0" styleClass="anchor" stylesheets="@style.css" xmlns="http://javafx.com/javafx/17"
xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.conway.ConwayController">
<GridPane styleClass="grid" fx:id="gameGrid" layoutX="85.0" layoutY="87.0" onMouseClicked="#cellClicked" prefHeight="230.0" prefWidth="431.0">
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="382.0" prefWidth="600.0" styleClass="anchor" stylesheets="@style.css" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.conway.ConwayController">
<GridPane fx:id="gameGrid" layoutX="85.0" layoutY="87.0" onMouseClicked="#cellClicked" prefHeight="230.0" prefWidth="431.0" styleClass="grid">
</GridPane>
<Button fx:id="startStop" layoutX="172.0" layoutY="356.0" mnemonicParsing="false" onAction="#startStopClicked" prefHeight="25.0" prefWidth="68.0" text="Start" />
<Button layoutX="354.0" layoutY="356.0" mnemonicParsing="false" onAction="#helpClicked" prefHeight="17.0" prefWidth="68.0" text="Help" />
<Button layoutX="266.0" layoutY="356.0" mnemonicParsing="false" onAction="#resetClicked" prefHeight="25.0" prefWidth="68.0" text="Reset" />
<Button fx:id="startStop" layoutX="175.0" layoutY="356.0" mnemonicParsing="false" onAction="#startStopClicked" prefHeight="25.0" prefWidth="68.0" text="Start" />
<Button layoutX="355.0" layoutY="356.0" mnemonicParsing="false" onAction="#helpClicked" prefHeight="17.0" prefWidth="68.0" text="Help" />
<Button layoutX="265.0" layoutY="356.0" mnemonicParsing="false" onAction="#resetClicked" prefHeight="25.0" prefWidth="68.0" text="Reset" />
<ImageView fitHeight="38.0" fitWidth="44.0" layoutX="154.0" layoutY="24.0" pickOnBounds="true" preserveRatio="true">
<Image url="@icon.png" />
</ImageView>
Expand All @@ -25,5 +23,9 @@
<Font name="System Bold" size="24.0" />
</font>
</Label>
<Slider fx:id="slider" layoutX="31.0" layoutY="114.0" max="1500.0" min="1.0" orientation="VERTICAL" value="500.0" />
<Slider fx:id="slider" layoutX="31.0" layoutY="114.0" max="1000.0" min="1" orientation="VERTICAL" rotate="180" value="500.0" />
<ImageView cache="true" cacheHint="QUALITY" fitHeight="25.0" fitWidth="32.0" layoutX="24.0" layoutY="87.0"
pickOnBounds="true" preserveRatio="true">
<Image url="@speedometer.png"/>
</ImageView>
</AnchorPane>
54 changes: 43 additions & 11 deletions src/main/resources/com/example/conway/help.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="541.0" styleClass="anchor"
stylesheets="@style.css" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.conway.HelpController">
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="351.0" prefWidth="541.0" styleClass="anchor" stylesheets="@style.css" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.conway.HelpController">
<ImageView fitHeight="38.0" fitWidth="44.0" layoutX="114.0" layoutY="36.0" pickOnBounds="true" preserveRatio="true">
<Image url="@icon.png" />
</ImageView>
Expand All @@ -21,18 +20,51 @@
<Font name="System Bold" size="24.0" />
</font>
</Label>
<Label layoutX="206.0" layoutY="85.0" text="Built by:" />
<ScrollPane layoutX="50.0" layoutY="160.0" prefHeight="200.0" prefWidth="440.0">
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="248.0" prefWidth="419.0" styleClass="scrollinternal">
<Text fx:id="textArea" fill="WHITE" layoutX="14.0" layoutY="27.0" strokeType="OUTSIDE" strokeWidth="0.0" text="test" wrappingWidth="380.0" />
<Label layoutX="206.0" layoutY="94.0" text="Built by:" />
<ScrollPane fx:id="aboutPane" layoutX="50.0" layoutY="125.0" prefHeight="200.0" prefWidth="440.0">
<AnchorPane disable="true" minHeight="0.0" minWidth="0.0" prefHeight="199.0" prefWidth="419.0" styleClass="scrollinternal">
<Text fx:id="aboutText" fill="WHITE" layoutX="14.0" layoutY="27.0" strokeType="OUTSIDE" strokeWidth="0.0" text="test" wrappingWidth="380.0" />
</AnchorPane>
</ScrollPane>
<Hyperlink layoutX="270.0" layoutY="82.0" text="Glowstick" onAction="#glowstickClicked"/>
<MenuButton layoutX="50.0" layoutY="116.0" mnemonicParsing="false" text="MenuButton">
<ScrollPane fx:id="rulesPane" layoutX="50.0" layoutY="125.0" prefHeight="200.0" prefWidth="440.0" visible="false">
<AnchorPane disable="true" minHeight="0.0" minWidth="0.0" prefHeight="350.0" prefWidth="419.0" styleClass="scrollinternal">
<Text fx:id="rulesText" fill="WHITE" layoutX="20.0" layoutY="54.0" strokeType="OUTSIDE" strokeWidth="0.0" text="test" wrappingWidth="240.0" />
<Text fill="WHITE" layoutX="14.0" layoutY="27.0" strokeType="OUTSIDE" strokeWidth="0.0" text="For a cell that is populated:">
<font>
<Font name="System Bold" size="12.0" />
</font>
</Text>
<ImageView fitHeight="55.0" fitWidth="126.0" layoutX="273.0" layoutY="35.0" pickOnBounds="true" preserveRatio="true">
<Image url="@solitude.png" />
</ImageView>
<ImageView fitHeight="55.0" fitWidth="126.0" layoutX="273.0" layoutY="106.0" pickOnBounds="true" preserveRatio="true">
<Image url="@overpopulation.png" />
</ImageView>
<ImageView fitHeight="55.0" fitWidth="126.0" layoutX="273.0" layoutY="171.0" pickOnBounds="true" preserveRatio="true">
<Image url="@survive.png" />
</ImageView>
<ImageView fitHeight="55.0" fitWidth="126.0" layoutX="273.0" layoutY="267.0" pickOnBounds="true" preserveRatio="true">
<Image url="@born.png" />
</ImageView>
<Text fill="WHITE" layoutX="14.0" layoutY="253.0" strokeType="OUTSIDE" strokeWidth="0.0" text="For a space that is empty or unpopulated:">
<font>
<Font name="System Bold" size="12.0" />
</font>
</Text>
</AnchorPane>
</ScrollPane>
<ScrollPane fx:id="controlPane" layoutX="50.0" layoutY="125.0" prefHeight="200.0" prefWidth="440.0" visible="false">
<AnchorPane disable="true" minHeight="0.0" minWidth="0.0" prefHeight="199.0" prefWidth="419.0" styleClass="scrollinternal">
<Text fx:id="controlsText" fill="WHITE" layoutX="14.0" layoutY="27.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Choose a pattern from the or make one yourself by clicking on the cells. The 'Start' button advances the game by several generations (each new generation corresponding to one iteration of the rules)." wrappingWidth="380.0" />
</AnchorPane>
</ScrollPane>
<Hyperlink fx:id="lexiconLink" layoutX="205.0" layoutY="137.0" onMouseClicked="#lexiconClick" text="Lexicon" textFill="#00aaf8" visible="false"/>
<Hyperlink layoutX="274.0" layoutY="91.0" onAction="#glowstickClicked" text="Glowstick" />
<MenuButton fx:id="menuButton" layoutX="50.0" layoutY="90.0" mnemonicParsing="false" text="About">
<items>
<MenuItem mnemonicParsing="false" text="About" />
<MenuItem mnemonicParsing="false" text="Rules" />
<MenuItem mnemonicParsing="false" text="Controls" />
<MenuItem mnemonicParsing="false" onAction="#onAboutClick" text="About" />
<MenuItem mnemonicParsing="false" onAction="#onRulesClick" text="Rules" />
<MenuItem mnemonicParsing="false" onAction="#onControlsClick" text="Controls" />
</items>
</MenuButton>
</AnchorPane>
Binary file modified src/main/resources/com/example/conway/icon.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.
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 added src/main/resources/com/example/conway/survive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6a4aa45

Please sign in to comment.