just need finishing touches..

This commit is contained in:
Sid 2022-11-13 01:33:02 +01:00
parent 5617274b4a
commit 01c6498339
32 changed files with 561 additions and 110 deletions

View file

@ -5,18 +5,18 @@
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="400.0" style="-fx-background-color: #252525;" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controllers.CreditsSceneController">
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="400.0" style="-fx-background-color: #252525;" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controllers.CreditsSceneController">
<children>
<Button layoutX="113.0" layoutY="438.0" mnemonicParsing="false" onAction="#btnMenuClicked" prefHeight="27.0" prefWidth="174.0" style="-fx-background-color: white;" text="Go back to Menu">
<Button layoutX="114.0" layoutY="511.0" mnemonicParsing="false" onAction="#btnMenuClicked" prefHeight="53.0" prefWidth="174.0" style="-fx-background-color: white;" text="Go back to Menu">
<font>
<Font name="Bodoni MT Black" size="12.0" />
<Font name="Bodoni MT Black" size="16.0" />
</font></Button>
<Label layoutX="142.0" layoutY="39.0" text="Credits" textFill="WHITE">
<Label layoutX="114.0" layoutY="54.0" text="Credits" textFill="WHITE">
<font>
<Font name="System Bold" size="36.0" />
<Font name="System Bold" size="53.0" />
</font>
</Label>
<Label layoutX="15.0" layoutY="92.0" prefHeight="290.0" prefWidth="372.0" textFill="WHITE">
<Label layoutX="15.0" layoutY="155.0" prefHeight="290.0" prefWidth="372.0" textFill="WHITE">
<font>
<Font size="18.0" />
</font>

View file

@ -8,49 +8,50 @@
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="400.0" style="-fx-background-color: #252525;" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controllers.GameSceneController">
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="400.0" style="-fx-background-color: #252525;" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controllers.GameSceneController">
<children>
<ImageView fitHeight="204.0" fitWidth="210.0" layoutX="98.0" layoutY="-34.0" pickOnBounds="true" preserveRatio="true">
<ImageView fitHeight="269.0" fitWidth="293.0" layoutX="66.0" layoutY="-53.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../logo4.jpg" />
<Image url="@../logo_final.png" />
</image>
</ImageView>
<Button layoutX="335.0" layoutY="448.0" mnemonicParsing="false" onAction="#btnResetClicked" prefHeight="10.0" prefWidth="58.0" style="-fx-background-color: white;" text="Reset" textFill="RED">
<Button fx:id="resetBtn" layoutX="158.0" layoutY="519.0" mnemonicParsing="false" onAction="#btnResetClicked" prefHeight="22.0" prefWidth="85.0" style="-fx-background-color: white;" text="New Game" textFill="RED">
<font>
<Font name="Bodoni MT Black" size="12.0" />
</font>
</Button>
<TextField layoutX="74.0" layoutY="442.0" prefHeight="33.0" prefWidth="186.0" promptText="Write a word here!" style="-fx-background-color: #5166A9; -fx-border-color: white;" />
<Button layoutX="269.0" layoutY="442.0" mnemonicParsing="false" onAction="#btnGoClicked" prefHeight="33.0" prefWidth="58.0" style="-fx-background-color: white;" text="Go">
<TextField fx:id="userInput" layoutX="78.0" layoutY="471.0" prefHeight="33.0" prefWidth="186.0" promptText="Write a word here!" style="-fx-background-color: #4f86f7; -fx-border-color: #4f86f7;" />
<Button fx:id="goBtn" layoutX="273.0" layoutY="471.0" mnemonicParsing="false" onAction="#btnGoClicked" prefHeight="33.0" prefWidth="58.0" style="-fx-background-color: white;" text="Go">
<font>
<Font name="Bodoni MT Black" size="14.0" />
</font>
</Button>
<Label fx:id="lb1" layoutX="55.0" layoutY="134.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="115.0" layoutY="134.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="175.0" layoutY="134.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="235.0" layoutY="134.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="295.0" layoutY="134.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="55.0" layoutY="194.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="115.0" layoutY="194.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="175.0" layoutY="194.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="235.0" layoutY="194.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="295.0" layoutY="194.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="55.0" layoutY="254.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="115.0" layoutY="254.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="175.0" layoutY="254.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="235.0" layoutY="254.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="295.0" layoutY="254.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="55.0" layoutY="314.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="115.0" layoutY="314.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="175.0" layoutY="314.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="235.0" layoutY="314.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="295.0" layoutY="314.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="55.0" layoutY="374.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="115.0" layoutY="374.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="175.0" layoutY="374.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="235.0" layoutY="374.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="295.0" layoutY="374.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Button layoutX="130.0" layoutY="14.0" mnemonicParsing="false" onAction="#btnMenuClicked" prefHeight="107.0" prefWidth="148.0" style="-fx-background-color: transparent;" textFill="TRANSPARENT" />
<Label fx:id="lb1" layoutX="55.0" layoutY="163.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb2" layoutX="115.0" layoutY="163.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb3" layoutX="175.0" layoutY="163.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb4" layoutX="235.0" layoutY="163.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb5" layoutX="295.0" layoutY="163.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb6" layoutX="55.0" layoutY="223.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb7" layoutX="115.0" layoutY="223.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb8" layoutX="175.0" layoutY="223.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb9" layoutX="235.0" layoutY="223.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb10" layoutX="295.0" layoutY="223.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb11" layoutX="55.0" layoutY="283.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb12" layoutX="115.0" layoutY="283.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb13" layoutX="175.0" layoutY="283.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb14" layoutX="235.0" layoutY="283.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb15" layoutX="295.0" layoutY="283.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb16" layoutX="55.0" layoutY="343.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb17" layoutX="115.0" layoutY="343.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb18" layoutX="175.0" layoutY="343.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb19" layoutX="235.0" layoutY="343.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb20" layoutX="295.0" layoutY="343.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb21" layoutX="55.0" layoutY="403.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb22" layoutX="115.0" layoutY="403.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb23" layoutX="175.0" layoutY="403.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb24" layoutX="235.0" layoutY="403.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb25" layoutX="295.0" layoutY="403.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Button layoutX="105.0" layoutY="20.0" mnemonicParsing="false" onAction="#btnMenuClicked" prefHeight="123.0" prefWidth="195.0" style="-fx-background-color: transparent;" text="s" textFill="TRANSPARENT" />
<Label fx:id="endgame" alignment="CENTER" contentDisplay="CENTER" layoutX="142.0" layoutY="553.0" prefHeight="33.0" prefWidth="121.0" textAlignment="CENTER" textFill="WHITE" />
</children>
</AnchorPane>

View file

@ -6,24 +6,24 @@
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="400.0" style="-fx-background-color: #252525;" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controllers.MainSceneController">
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="400.0" style="-fx-background-color: #252525;" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controllers.MainSceneController">
<children>
<ImageView fitHeight="400.0" fitWidth="413.0" layoutY="-48.0" pickOnBounds="true" preserveRatio="true">
<ImageView fitHeight="478.0" fitWidth="482.0" layoutX="-38.0" layoutY="-65.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../logo4.jpg" />
<Image url="@../logo_final.png" />
</image>
</ImageView>
<Button layoutX="115.0" layoutY="275.0" mnemonicParsing="false" onAction="#btnPlayClicked" prefHeight="53.0" prefWidth="171.0" style="-fx-background-color: white;" text="Play">
<Button layoutX="115.0" layoutY="329.0" mnemonicParsing="false" onAction="#btnPlayClicked" prefHeight="53.0" prefWidth="171.0" style="-fx-background-color: white;" text="Play">
<font>
<Font name="Bodoni MT Black" size="24.0" />
</font>
</Button>
<Button layoutX="115.0" layoutY="342.0" mnemonicParsing="false" onAction="#btnRulesClicked" prefHeight="53.0" prefWidth="171.0" style="-fx-background-color: white;" text="How to Play">
<Button layoutX="115.0" layoutY="415.0" mnemonicParsing="false" onAction="#btnRulesClicked" prefHeight="53.0" prefWidth="171.0" style="-fx-background-color: white;" text="How to Play">
<font>
<Font name="Bodoni MT Black" size="18.0" />
</font>
</Button>
<Button layoutX="115.0" layoutY="410.0" mnemonicParsing="false" onAction="#btnCreditsClicked" prefHeight="53.0" prefWidth="171.0" style="-fx-background-color: white;" text="Credits">
<Button layoutX="115.0" layoutY="502.0" mnemonicParsing="false" onAction="#btnCreditsClicked" prefHeight="53.0" prefWidth="171.0" style="-fx-background-color: white;" text="Credits">
<font>
<Font name="Bodoni MT Black" size="24.0" />
</font>

View file

@ -5,18 +5,18 @@
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="400.0" style="-fx-background-color: #252525;" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controllers.RulesSceneController">
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="400.0" style="-fx-background-color: #252525;" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controllers.RulesSceneController">
<children>
<Button layoutX="113.0" layoutY="438.0" mnemonicParsing="false" onAction="#btnMenuClicked" prefHeight="27.0" prefWidth="174.0" style="-fx-background-color: white;" text="Go back to Menu">
<Button layoutX="114.0" layoutY="511.0" mnemonicParsing="false" onAction="#btnMenuClicked" prefHeight="53.0" prefWidth="174.0" style="-fx-background-color: white;" text="Go back to Menu">
<font>
<Font name="Bodoni MT Black" size="12.0" />
<Font name="Bodoni MT Black" size="16.0" />
</font></Button>
<Label layoutX="98.0" layoutY="39.0" text="How to Play" textFill="WHITE">
<Label layoutX="50.0" layoutY="54.0" text="How to Play" textFill="WHITE">
<font>
<Font name="System Bold" size="36.0" />
<Font name="System Bold" size="53.0" />
</font>
</Label>
<Label layoutX="15.0" layoutY="92.0" prefHeight="290.0" prefWidth="372.0" text="1. Lorem ipasum ...&#10;2. tseter&#10;3. wow&#10;4. ok&#10;5. shit" textFill="WHITE">
<Label layoutX="16.0" layoutY="155.0" prefHeight="290.0" prefWidth="372.0" text="1. Lorem ipasum ...&#10;2. tseter&#10;3. wow&#10;4. ok&#10;5. shit" textFill="WHITE">
<font>
<Font size="18.0" />
</font>

Binary file not shown.

BIN
bin/Objects/Testing.class Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

BIN
bin/logo_final.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

5
gameWords.txt Normal file
View file

@ -0,0 +1,5 @@
moren
konge
anime
feste
bønne

25
legalWords.txt Normal file
View file

@ -0,0 +1,25 @@
treet
hoppe
leppe
sitte
lefse
model
lampe
proff
miste
huset
båten
låten
leste
mange
danse
dyner
mobil
tenke
senke
faren
moren
konge
anime
feste
bønne

View file

@ -2,35 +2,211 @@ package Controllers;
import java.io.IOException;
import Objects.WordleGame;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class GameSceneController {
// Event Listener on Button.onAction
private WordleGame game = new WordleGame();
private int[] correctChars;
private Label one, two, three, four, five; // Labels for words and colorchanging
// @FXML variables
@FXML
public void btnResetClicked(ActionEvent event) {
// TODO Autogenerated
}
private Label lb1, lb2, lb3, lb4, lb5,
lb6, lb7, lb8, lb9, lb10,
lb11, lb12, lb13, lb14, lb15,
lb16, lb17, lb18, lb19, lb20,
lb21, lb22, lb23, lb24, lb25;
@FXML
private TextField userInput;
@FXML
private Button goBtn;
@FXML
private Button resetBtn;
@FXML
private Label endgame;
// Event Listener on Button.onAction
/*
* Checks and outputs if users guessed word is
* legal or not, and will show result of each
* guess to user.
* Includes also a winning and losing screen. ****
*/
@FXML
public void btnGoClicked(ActionEvent event) {
// TODO Autogenerated
String userGuess = userInput.getText().toLowerCase();
game.setCurrentGuess(userGuess);
setRows();
// Checks if userGuess is legal or not
if (game.isWordLegal(userGuess)) {
userGuess = userGuess.toUpperCase();
char[] letters = userGuess.toCharArray();
// Letters to labels
one.setText("" + letters[0] + "");
two.setText("" + letters[1] + "");
three.setText("" + letters[2] + "");
four.setText("" + letters[3] + "");
five.setText("" + letters[4] + "");
// Colorchange
correctChars = game.charChecker();
colorChanger(correctChars[0], one);
colorChanger(correctChars[1], two);
colorChanger(correctChars[2], three);
colorChanger(correctChars[3], four);
colorChanger(correctChars[4], five);
game.nextRow();
} else {
userInput.setPromptText("Not a legal word!");
}
// if game.correctWord
if (game.correctWord()) {
endgame.setText("YOU WON!");
endgame.setTextFill(Color.GREEN);
}
// if getCurrentRow < 5 - you lost new game x setup
if (game.getCurrentRow() > 5) {
endgame.setText("YOU LOST!");
endgame.setTextFill(Color.RED);
}
// Clears inputfield for next guess
userInput.setText("");
}
// Event Listener on Button.onAction
/*
* Resets userinput field and all labels
*/
@FXML
public void btnResetClicked(ActionEvent event) {
userInput.setPromptText("Write a word here!");
newGameSetup();
}
// Event Listener on Button.onAction
/*
* Goes back to menu when logo is clicked
*/
@FXML
public void btnMenuClicked(ActionEvent event) throws IOException {
Parent gameSceneParent = FXMLLoader.load(getClass().getResource("/FXML/MainScene.fxml"));
Scene gameScene = new Scene(gameSceneParent);
Parent menuSceneParent = FXMLLoader.load(getClass().getResource("/FXML/MainScene.fxml"));
Scene menuScene = new Scene(menuSceneParent);
Stage window = (Stage) ((Node)event.getSource()).getScene().getWindow();
window.setTitle("Sids Wordle");
window.setScene(gameScene);
window.setScene(menuScene);
window.show();
}
/*
* Fixes setup for each row in the game
*/
private void setRows() {
switch(game.getCurrentRow()) {
case 1:
one = lb1;
two = lb2;
three = lb3;
four = lb4;
five = lb5;
break;
case 2:
one = lb6;
two = lb7;
three = lb8;
four = lb9;
five = lb10;
break;
case 3:
one = lb11;
two = lb12;
three = lb13;
four = lb14;
five = lb15;
break;
case 4:
one = lb16;
two = lb17;
three = lb18;
four = lb19;
five = lb20;
break;
case 5:
one = lb21;
two = lb22;
three = lb23;
four = lb24;
five = lb25;
break;
}
}
/*
* Fixes setup for a new game, and resets
* both color and text for all labels
*/
private void newGameSetup() {
game = new WordleGame();
endgame.setText("");
Label[] labels = {
lb1, lb2, lb3, lb4, lb5,
lb6, lb7, lb8, lb9, lb10,
lb11, lb12, lb13, lb14, lb15,
lb16, lb17, lb18, lb19, lb20,
lb21, lb22, lb23, lb24, lb25
};
for (int i = 0; i < labels.length; i++) {
labels[i].setText("");
labels[i].setStyle("-fx-background-color: lightgrey;");
}
}
/*
* Changes colors of labels to show user
* which letters of current guess are:
* 0) wrong (not in gameword)
* 1) correct, but in wrong place
* 2) correct and in right place
*
* @param x -> each case mentioned over^
* @param y -> which label to change background on
*/
private void colorChanger(int x, Label y) {
switch(x) {
case 0:
y.setStyle("-fx-background-color: lightgrey;");
break;
case 1:
y.setStyle("-fx-background-color: yellow;");
break;
case 2:
y.setStyle("-fx-background-color: green;");
break;
}
}
}

View file

@ -5,18 +5,18 @@
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="400.0" style="-fx-background-color: #252525;" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controllers.CreditsSceneController">
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="400.0" style="-fx-background-color: #252525;" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controllers.CreditsSceneController">
<children>
<Button layoutX="113.0" layoutY="438.0" mnemonicParsing="false" onAction="#btnMenuClicked" prefHeight="27.0" prefWidth="174.0" style="-fx-background-color: white;" text="Go back to Menu">
<Button layoutX="114.0" layoutY="511.0" mnemonicParsing="false" onAction="#btnMenuClicked" prefHeight="53.0" prefWidth="174.0" style="-fx-background-color: white;" text="Go back to Menu">
<font>
<Font name="Bodoni MT Black" size="12.0" />
<Font name="Bodoni MT Black" size="16.0" />
</font></Button>
<Label layoutX="142.0" layoutY="39.0" text="Credits" textFill="WHITE">
<Label layoutX="114.0" layoutY="54.0" text="Credits" textFill="WHITE">
<font>
<Font name="System Bold" size="36.0" />
<Font name="System Bold" size="53.0" />
</font>
</Label>
<Label layoutX="15.0" layoutY="92.0" prefHeight="290.0" prefWidth="372.0" textFill="WHITE">
<Label layoutX="15.0" layoutY="155.0" prefHeight="290.0" prefWidth="372.0" textFill="WHITE">
<font>
<Font size="18.0" />
</font>

View file

@ -8,49 +8,50 @@
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="400.0" style="-fx-background-color: #252525;" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controllers.GameSceneController">
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="400.0" style="-fx-background-color: #252525;" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controllers.GameSceneController">
<children>
<ImageView fitHeight="204.0" fitWidth="210.0" layoutX="98.0" layoutY="-34.0" pickOnBounds="true" preserveRatio="true">
<ImageView fitHeight="269.0" fitWidth="293.0" layoutX="66.0" layoutY="-53.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../logo4.jpg" />
<Image url="@../logo_final.png" />
</image>
</ImageView>
<Button layoutX="335.0" layoutY="448.0" mnemonicParsing="false" onAction="#btnResetClicked" prefHeight="10.0" prefWidth="58.0" style="-fx-background-color: white;" text="Reset" textFill="RED">
<Button fx:id="resetBtn" layoutX="158.0" layoutY="519.0" mnemonicParsing="false" onAction="#btnResetClicked" prefHeight="22.0" prefWidth="85.0" style="-fx-background-color: white;" text="New Game" textFill="RED">
<font>
<Font name="Bodoni MT Black" size="12.0" />
</font>
</Button>
<TextField layoutX="74.0" layoutY="442.0" prefHeight="33.0" prefWidth="186.0" promptText="Write a word here!" style="-fx-background-color: #5166A9; -fx-border-color: white;" />
<Button layoutX="269.0" layoutY="442.0" mnemonicParsing="false" onAction="#btnGoClicked" prefHeight="33.0" prefWidth="58.0" style="-fx-background-color: white;" text="Go">
<TextField fx:id="userInput" layoutX="78.0" layoutY="471.0" prefHeight="33.0" prefWidth="186.0" promptText="Write a word here!" style="-fx-background-color: #4f86f7; -fx-border-color: #4f86f7;" />
<Button fx:id="goBtn" layoutX="273.0" layoutY="471.0" mnemonicParsing="false" onAction="#btnGoClicked" prefHeight="33.0" prefWidth="58.0" style="-fx-background-color: white;" text="Go">
<font>
<Font name="Bodoni MT Black" size="14.0" />
</font>
</Button>
<Label fx:id="lb1" layoutX="55.0" layoutY="134.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="115.0" layoutY="134.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="175.0" layoutY="134.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="235.0" layoutY="134.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="295.0" layoutY="134.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="55.0" layoutY="194.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="115.0" layoutY="194.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="175.0" layoutY="194.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="235.0" layoutY="194.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="295.0" layoutY="194.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="55.0" layoutY="254.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="115.0" layoutY="254.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="175.0" layoutY="254.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="235.0" layoutY="254.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="295.0" layoutY="254.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="55.0" layoutY="314.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="115.0" layoutY="314.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="175.0" layoutY="314.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="235.0" layoutY="314.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="295.0" layoutY="314.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="55.0" layoutY="374.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="115.0" layoutY="374.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="175.0" layoutY="374.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="235.0" layoutY="374.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label layoutX="295.0" layoutY="374.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Button layoutX="130.0" layoutY="14.0" mnemonicParsing="false" onAction="#btnMenuClicked" prefHeight="107.0" prefWidth="148.0" style="-fx-background-color: transparent;" textFill="TRANSPARENT" />
<Label fx:id="lb1" layoutX="55.0" layoutY="163.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb2" layoutX="115.0" layoutY="163.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb3" layoutX="175.0" layoutY="163.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb4" layoutX="235.0" layoutY="163.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb5" layoutX="295.0" layoutY="163.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb6" layoutX="55.0" layoutY="223.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb7" layoutX="115.0" layoutY="223.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb8" layoutX="175.0" layoutY="223.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb9" layoutX="235.0" layoutY="223.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb10" layoutX="295.0" layoutY="223.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb11" layoutX="55.0" layoutY="283.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb12" layoutX="115.0" layoutY="283.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb13" layoutX="175.0" layoutY="283.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb14" layoutX="235.0" layoutY="283.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb15" layoutX="295.0" layoutY="283.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb16" layoutX="55.0" layoutY="343.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb17" layoutX="115.0" layoutY="343.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb18" layoutX="175.0" layoutY="343.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb19" layoutX="235.0" layoutY="343.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb20" layoutX="295.0" layoutY="343.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb21" layoutX="55.0" layoutY="403.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb22" layoutX="115.0" layoutY="403.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb23" layoutX="175.0" layoutY="403.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb24" layoutX="235.0" layoutY="403.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Label fx:id="lb25" layoutX="295.0" layoutY="403.0" prefHeight="50.0" prefWidth="50.0" style="-fx-background-color: lightgrey;" />
<Button layoutX="105.0" layoutY="20.0" mnemonicParsing="false" onAction="#btnMenuClicked" prefHeight="123.0" prefWidth="195.0" style="-fx-background-color: transparent;" text="s" textFill="TRANSPARENT" />
<Label fx:id="endgame" alignment="CENTER" contentDisplay="CENTER" layoutX="142.0" layoutY="553.0" prefHeight="33.0" prefWidth="121.0" textAlignment="CENTER" textFill="WHITE" />
</children>
</AnchorPane>

View file

@ -6,24 +6,24 @@
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="400.0" style="-fx-background-color: #252525;" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controllers.MainSceneController">
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="400.0" style="-fx-background-color: #252525;" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controllers.MainSceneController">
<children>
<ImageView fitHeight="400.0" fitWidth="413.0" layoutY="-48.0" pickOnBounds="true" preserveRatio="true">
<ImageView fitHeight="478.0" fitWidth="482.0" layoutX="-38.0" layoutY="-65.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../logo4.jpg" />
<Image url="@../logo_final.png" />
</image>
</ImageView>
<Button layoutX="115.0" layoutY="275.0" mnemonicParsing="false" onAction="#btnPlayClicked" prefHeight="53.0" prefWidth="171.0" style="-fx-background-color: white;" text="Play">
<Button layoutX="115.0" layoutY="329.0" mnemonicParsing="false" onAction="#btnPlayClicked" prefHeight="53.0" prefWidth="171.0" style="-fx-background-color: white;" text="Play">
<font>
<Font name="Bodoni MT Black" size="24.0" />
</font>
</Button>
<Button layoutX="115.0" layoutY="342.0" mnemonicParsing="false" onAction="#btnRulesClicked" prefHeight="53.0" prefWidth="171.0" style="-fx-background-color: white;" text="How to Play">
<Button layoutX="115.0" layoutY="415.0" mnemonicParsing="false" onAction="#btnRulesClicked" prefHeight="53.0" prefWidth="171.0" style="-fx-background-color: white;" text="How to Play">
<font>
<Font name="Bodoni MT Black" size="18.0" />
</font>
</Button>
<Button layoutX="115.0" layoutY="410.0" mnemonicParsing="false" onAction="#btnCreditsClicked" prefHeight="53.0" prefWidth="171.0" style="-fx-background-color: white;" text="Credits">
<Button layoutX="115.0" layoutY="502.0" mnemonicParsing="false" onAction="#btnCreditsClicked" prefHeight="53.0" prefWidth="171.0" style="-fx-background-color: white;" text="Credits">
<font>
<Font name="Bodoni MT Black" size="24.0" />
</font>

View file

@ -5,18 +5,18 @@
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="400.0" style="-fx-background-color: #252525;" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controllers.RulesSceneController">
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="400.0" style="-fx-background-color: #252525;" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controllers.RulesSceneController">
<children>
<Button layoutX="113.0" layoutY="438.0" mnemonicParsing="false" onAction="#btnMenuClicked" prefHeight="27.0" prefWidth="174.0" style="-fx-background-color: white;" text="Go back to Menu">
<Button layoutX="114.0" layoutY="511.0" mnemonicParsing="false" onAction="#btnMenuClicked" prefHeight="53.0" prefWidth="174.0" style="-fx-background-color: white;" text="Go back to Menu">
<font>
<Font name="Bodoni MT Black" size="12.0" />
<Font name="Bodoni MT Black" size="16.0" />
</font></Button>
<Label layoutX="98.0" layoutY="39.0" text="How to Play" textFill="WHITE">
<Label layoutX="50.0" layoutY="54.0" text="How to Play" textFill="WHITE">
<font>
<Font name="System Bold" size="36.0" />
<Font name="System Bold" size="53.0" />
</font>
</Label>
<Label layoutX="15.0" layoutY="92.0" prefHeight="290.0" prefWidth="372.0" text="1. Lorem ipasum ...&#10;2. tseter&#10;3. wow&#10;4. ok&#10;5. shit" textFill="WHITE">
<Label layoutX="16.0" layoutY="155.0" prefHeight="290.0" prefWidth="372.0" text="1. Lorem ipasum ...&#10;2. tseter&#10;3. wow&#10;4. ok&#10;5. shit" textFill="WHITE">
<font>
<Font size="18.0" />
</font>

View file

@ -0,0 +1,84 @@
/*
* Interface for WordleGame.
* - Made for controlling functions in a game.
*/
package Interfaces;
public interface WordleInterface {
/* Objectvariables
* ----------------
* String gameWord;
* String currentWord;
* int currentRow;
*/
/*
* Generates random word for each game
* taken from a .txt file in the project
* folder.
*
* @return string containing the word of the game
*/
public String randomGameWord();
/*
* Takes input from user and checks
* a .txt file (containing all legal words)
* in the project folder, and checks if
* it's legal.
*
* @param word userinput in form of variable "currentWord"
*
* @return true if the word is legal
*/
public boolean isWordLegal(String word);
/*
* Checks if users current input
* is equal to the word of the game.
*
* @return true if word is equal
*/
public boolean correctWord();
/*
* Takes users current word into an array,
* and checks each char for if they are correct
* and in the right place (1), or if they are correct,
* but in the wrong place (2). Char not in word (0).
*
* @return int[] containing values for each char in word & their status
*/
public int[] charChecker();
/*
* Keeps track of rowes with variable "currentRow"
* and the amount of users guesses.
* Will also help to reset variable "currentWord" for
* each guess.
*
* @return false if currentRow == 5 user has lost
*/
public boolean nextRow();
/*
* SETTERS:
* - setCurrentGuess
* - setCurrentRow
*/
public void setCurrentGuess(String word); // Sets variable "currentWord" to users latest guess
public void setCurrentRow(int x); // Sets variable "currentRow" to games current row
/*
* GETTERS:
* - getGameWord
* - getCurrentGuess
* - getCurrentRow
*/
public String getGameWord(); // gets word of the game
public String getCurrentGuess(); // gets users current guess
public int getCurrentRow(); // gets current row
}

20
src/Objects/Testing.java Normal file
View file

@ -0,0 +1,20 @@
package Objects;
public class Testing {
public static void main(String[] args) {
WordleGame game = new WordleGame();
// Testing randomGameWord()-method
System.out.println(game.randomGameWord());
// Testing isWordLegal()-method
String falseWord = "wordle";
String correctWord = "feste";
System.out.println("'wordle' is " + game.isWordLegal(falseWord)
+ ", and 'feste' is " + game.isWordLegal(correctWord));
}
}

138
src/Objects/WordleGame.java Normal file
View file

@ -0,0 +1,138 @@
package Objects;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import Interfaces.WordleInterface;
public class WordleGame implements WordleInterface {
private String gameWord;
private String currentWord;
private int currentRow;
public WordleGame() {
gameWord = randomGameWord();
currentRow = 1;
}
/*
* Generates random word for each game
* taken from a .txt file in the project
* folder.
*
* @return string containing the word of the game
*/
@Override
public String randomGameWord() {
String randomWordOfGame = "";
try {
String[] words = new String[6];
int i = 0;
Scanner scan = new Scanner(new File("gameWords.txt"));
while (scan.hasNext()) {
words[i] = scan.nextLine();
i++;
}
int random = (int) (Math.random() * i);
randomWordOfGame = words[random];
scan.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return randomWordOfGame;
}
@Override
public boolean isWordLegal(String word) {
boolean legal = false;
// Gets list containing legal words
String[] wordlist = new String[26];
try {
int i = 0;
Scanner scan = new Scanner(new File("legalWords.txt"));
while (scan.hasNext()) {
wordlist[i] = scan.nextLine();
i++;
}
scan.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
// Compares words in wordlist with "word" to check if word is legal¨
for (int i = 0; wordlist[i] != null; i++) {
if (wordlist[i].equals(word)) {
legal = true;
}
}
return legal;
}
@Override
public boolean correctWord() {
return currentWord.equalsIgnoreCase(gameWord);
}
@Override
public int[] charChecker() {
int[] charStatuses = new int[5];
for (int i = 0; i < gameWord.length(); i++) {
String correctWordCS = gameWord.charAt(i) + "";
String userWordCS = currentWord.charAt(i) + "";
if (correctWordCS.contentEquals(userWordCS)) {
charStatuses[i] = 2;
} else if (gameWord.contains(userWordCS)) {
charStatuses[i] = 1;
} else {
charStatuses[i] = 0;
}
}
return charStatuses;
}
@Override
public boolean nextRow() {
currentRow++;
return true;
}
@Override
public void setCurrentGuess(String word) {
currentWord = word;
}
@Override
public void setCurrentRow(int x) {
currentRow = x;
}
@Override
public String getGameWord() {
return gameWord;
}
@Override
public String getCurrentGuess() {
return currentWord;
}
@Override
public int getCurrentRow() {
return currentRow;
}
}

View file

@ -14,8 +14,9 @@ public class Main extends Application {
Parent root = FXMLLoader.load(getClass().getResource("/FXML/MainScene.fxml"));
Scene scene = new Scene(root);
primaryStage.setTitle("Sids Wordle!");
primaryStage.setTitle("Sids Wordle");
primaryStage.setScene(scene);
primaryStage.setResizable(false);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

BIN
src/logo_final.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB