Upload files
7
HangmanFx/.classpath
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.fx.ide.jdt.core.JAVAFX_CONTAINER"/>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
1
HangmanFx/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/bin/
|
23
HangmanFx/.project
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>HangmanFx</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
12
HangmanFx/.settings/org.eclipse.jdt.core.prefs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.release=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.source=1.8
|
8
HangmanFx/build.fxbuild
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="ASCII"?>
|
||||||
|
<anttasks:AntTask xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:anttasks="http://org.eclipse.fx.ide.jdt/1.0" buildDirectory="${project}/build">
|
||||||
|
<deploy>
|
||||||
|
<application name="HangmanFx"/>
|
||||||
|
<info/>
|
||||||
|
</deploy>
|
||||||
|
<signjar/>
|
||||||
|
</anttasks:AntTask>
|
32
HangmanFx/src/application/HangmanPreload.java
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
package application;
|
||||||
|
|
||||||
|
import javafx.application.Preloader;
|
||||||
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.scene.Parent;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
import javafx.stage.StageStyle;
|
||||||
|
|
||||||
|
public class HangmanPreload extends Preloader {
|
||||||
|
|
||||||
|
private Stage preloaderStage;
|
||||||
|
private Scene scene;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() throws Exception {
|
||||||
|
Parent root1 = FXMLLoader.load(getClass().getResource("Preloader.fxml"));
|
||||||
|
scene = new Scene(root1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start(Stage primaryStage) throws Exception {
|
||||||
|
this.preloaderStage = primaryStage;
|
||||||
|
preloaderStage.setScene(scene);
|
||||||
|
preloaderStage.initStyle(StageStyle.UNDECORATED);
|
||||||
|
preloaderStage.show();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
139
HangmanFx/src/application/Main.java
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
package application;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import com.sun.javafx.application.LauncherImpl;
|
||||||
|
|
||||||
|
import javafx.application.Application;
|
||||||
|
import javafx.application.Preloader;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
import javafx.scene.Parent;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.control.TextField;
|
||||||
|
import javafx.scene.image.Image;
|
||||||
|
import javafx.scene.image.ImageView;
|
||||||
|
import javafx.scene.text.Text;
|
||||||
|
|
||||||
|
public class Main extends Application {
|
||||||
|
|
||||||
|
// Scenebuilder
|
||||||
|
@FXML
|
||||||
|
Text text;
|
||||||
|
@FXML
|
||||||
|
ImageView hangmanImage;
|
||||||
|
@FXML
|
||||||
|
TextField textField;
|
||||||
|
@FXML
|
||||||
|
Text info;
|
||||||
|
|
||||||
|
String wort;
|
||||||
|
String rightletterString;
|
||||||
|
|
||||||
|
char[] wortToArr;
|
||||||
|
char[] displayWord;
|
||||||
|
|
||||||
|
int counter = 1;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start(Stage primaryStage) {
|
||||||
|
try {
|
||||||
|
Parent root = FXMLLoader.load(getClass().getResource("Ui.fxml"));
|
||||||
|
|
||||||
|
Scene scene = new Scene(root);
|
||||||
|
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
|
||||||
|
primaryStage.setScene(scene);
|
||||||
|
primaryStage.setTitle("****HANGMAN****");
|
||||||
|
primaryStage.show();
|
||||||
|
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Button New Game
|
||||||
|
public void newGame() {
|
||||||
|
try {
|
||||||
|
wort = newWord();
|
||||||
|
wortToArr = wort.toCharArray();
|
||||||
|
displayWord = new char[wortToArr.length];
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < wort.length(); i++) {
|
||||||
|
displayWord[i] = '-';
|
||||||
|
}
|
||||||
|
String textfieldString = new String(displayWord);
|
||||||
|
text.setText(textfieldString);
|
||||||
|
counter = 1;
|
||||||
|
hangmanImage.setImage(null);
|
||||||
|
info.setText("");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check the letter input from Textfield
|
||||||
|
public boolean letterCheck(char[] wortToArr, char[] displayWord) {
|
||||||
|
|
||||||
|
for (int i = 0; i < wort.length(); i++) {
|
||||||
|
if (wortToArr[i] == textField.getText().charAt(0)) {
|
||||||
|
displayWord[i] = wortToArr[i];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Button to confirm\check typed Letter
|
||||||
|
public void checkLetter() {
|
||||||
|
info.setText("");
|
||||||
|
if (letterCheck(wortToArr, displayWord) == true) {
|
||||||
|
rightletterString = new String(displayWord);
|
||||||
|
text.setText(rightletterString);
|
||||||
|
info.setText("Richtig");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
hangmanImage.setImage(new Image("/images/" + counter + ".png"));
|
||||||
|
info.setText("Falsch");
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
textField.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns a Word from txt file
|
||||||
|
public String newWord() throws FileNotFoundException {
|
||||||
|
Random random = new Random();
|
||||||
|
String line;
|
||||||
|
ArrayList<String> temp = new ArrayList<String>();
|
||||||
|
InputStream in = getClass().getResourceAsStream("/wort.txt");
|
||||||
|
BufferedReader bf = new BufferedReader(new InputStreamReader(in));
|
||||||
|
try {
|
||||||
|
while ((line = bf.readLine()) != null) {
|
||||||
|
temp.add(line);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
|
||||||
|
e.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
return temp.get(random.nextInt(temp.size())).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
LauncherImpl.launchApplication(Main.class, HangmanPreload.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
16
HangmanFx/src/application/Preloader.fxml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.image.Image?>
|
||||||
|
<?import javafx.scene.image.ImageView?>
|
||||||
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
|
|
||||||
|
|
||||||
|
<AnchorPane xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/11.0.1">
|
||||||
|
<children>
|
||||||
|
<ImageView fitHeight="509.0" fitWidth="757.0" layoutX="-10.0" layoutY="-6.0">
|
||||||
|
<image>
|
||||||
|
<Image url="@../images/hangman.jpg" />
|
||||||
|
</image>
|
||||||
|
</ImageView>
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
41
HangmanFx/src/application/Ui.fxml
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
|
<?import javafx.scene.control.TextField?>
|
||||||
|
<?import javafx.scene.image.ImageView?>
|
||||||
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
|
<?import javafx.scene.text.Font?>
|
||||||
|
<?import javafx.scene.text.Text?>
|
||||||
|
|
||||||
|
<AnchorPane prefHeight="424.0" prefWidth="608.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.Main">
|
||||||
|
<children>
|
||||||
|
<ImageView fx:id="hangmanImage" fitHeight="190.0" fitWidth="262.0" layoutX="316.0" layoutY="140.0" pickOnBounds="true" preserveRatio="true" />
|
||||||
|
<TextField fx:id="textField" layoutX="37.0" layoutY="298.0" prefHeight="72.0" prefWidth="82.0" promptText="...">
|
||||||
|
<font>
|
||||||
|
<Font size="41.0" />
|
||||||
|
</font>
|
||||||
|
</TextField>
|
||||||
|
<Text fx:id="text" layoutX="224.0" layoutY="130.0" strokeType="OUTSIDE" strokeWidth="0.0" textAlignment="CENTER" wrappingWidth="359.13671875">
|
||||||
|
<font>
|
||||||
|
<Font size="54.0" />
|
||||||
|
</font>
|
||||||
|
</Text>
|
||||||
|
<Button layoutX="145.0" layoutY="329.0" mnemonicParsing="false" onAction="#checkLetter" text="Bestätigen" />
|
||||||
|
<Button layoutX="22.0" layoutY="29.0" mnemonicParsing="false" onAction="#newGame" text="New Game" />
|
||||||
|
<Text layoutX="22.0" layoutY="404.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Bitte einen Buchstaben eingeben" textAlignment="CENTER" wrappingWidth="295.0">
|
||||||
|
<font>
|
||||||
|
<Font size="18.0" />
|
||||||
|
</font>
|
||||||
|
</Text>
|
||||||
|
<Text layoutX="20.0" layoutY="117.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Zu erratendes Wort" textAlignment="CENTER" wrappingWidth="197.13671875">
|
||||||
|
<font>
|
||||||
|
<Font size="20.0" />
|
||||||
|
</font>
|
||||||
|
</Text>
|
||||||
|
<Text fx:id="info" fill="#f20808" layoutX="37.0" layoutY="205.0" strokeType="OUTSIDE" strokeWidth="0.0" wrappingWidth="137.13671875">
|
||||||
|
<font>
|
||||||
|
<Font size="25.0" />
|
||||||
|
</font>
|
||||||
|
</Text>
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
1
HangmanFx/src/application/application.css
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */
|
BIN
HangmanFx/src/images/1.png
Normal file
After Width: | Height: | Size: 4.6 KiB |
BIN
HangmanFx/src/images/10.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
HangmanFx/src/images/11.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
HangmanFx/src/images/12.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
HangmanFx/src/images/13.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
HangmanFx/src/images/14.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
HangmanFx/src/images/15.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
HangmanFx/src/images/2.png
Normal file
After Width: | Height: | Size: 5.6 KiB |
BIN
HangmanFx/src/images/3.png
Normal file
After Width: | Height: | Size: 6.4 KiB |
BIN
HangmanFx/src/images/4.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
HangmanFx/src/images/5.png
Normal file
After Width: | Height: | Size: 8.9 KiB |
BIN
HangmanFx/src/images/6.png
Normal file
After Width: | Height: | Size: 9.0 KiB |
BIN
HangmanFx/src/images/7.png
Normal file
After Width: | Height: | Size: 9.6 KiB |
BIN
HangmanFx/src/images/8.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
HangmanFx/src/images/9.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
HangmanFx/src/images/hangman.jpg
Normal file
After Width: | Height: | Size: 13 KiB |
50
HangmanFx/src/wort.txt
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
Umweltschutzorganisation
|
||||||
|
Nahrungsmittel
|
||||||
|
Fussballweltmeisterschaft
|
||||||
|
mutterseelenallein
|
||||||
|
Liebesabenteuer
|
||||||
|
Haftpflichtversicherung
|
||||||
|
Terroranschlag
|
||||||
|
Finanzdienstleistungsunternehmen
|
||||||
|
Unterrichtsschluss
|
||||||
|
Toilettenpapier
|
||||||
|
Dachpappe
|
||||||
|
Mumurubbler
|
||||||
|
Kuddelmuddel
|
||||||
|
Hupfdohle
|
||||||
|
Pipifax
|
||||||
|
Babypuppe
|
||||||
|
Gigolo
|
||||||
|
Vollmond
|
||||||
|
Verbalkloake
|
||||||
|
Quizshow
|
||||||
|
Finanzdienstleistungsunternehmen
|
||||||
|
Fussballweltmeisterschaft
|
||||||
|
Umweltschutzorganisation
|
||||||
|
Schifffahrtsgesellschaft
|
||||||
|
Haftpflichtversicherung
|
||||||
|
Brechreizbeschleuniger
|
||||||
|
Intelligenzallergiker
|
||||||
|
Steckdosenbefruchter
|
||||||
|
Wasserverschmutzung
|
||||||
|
Geschmacksverirrung
|
||||||
|
Sex
|
||||||
|
Hund
|
||||||
|
Oper
|
||||||
|
Mond
|
||||||
|
Yeti
|
||||||
|
Mars
|
||||||
|
Quiz
|
||||||
|
Auto
|
||||||
|
Zebra
|
||||||
|
Venus
|
||||||
|
Warenentgegennahme
|
||||||
|
Brechreizbeschleuniger
|
||||||
|
Kuddelmuddel
|
||||||
|
Geschlechtsverkehr
|
||||||
|
Verbalkloake
|
||||||
|
Papperlapapp
|
||||||
|
Intelligenzallergiker
|
||||||
|
Nippelpiercing
|
||||||
|
Steckdosenbefruchter
|
||||||
|
Mumurubbler
|