Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Tick-Tack-Trauma
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Josua Oppermann
Tick-Tack-Trauma
Commits
5a5832aa
Commit
5a5832aa
authored
1 month ago
by
David Reiser
Browse files
Options
Downloads
Patches
Plain Diff
new comments added
parent
4dcc0399
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+3
-2
3 additions, 2 deletions
.gitignore
.vscode/settings.json
+9
-1
9 additions, 1 deletion
.vscode/settings.json
GameUI.java
+12
-3
12 additions, 3 deletions
GameUI.java
with
24 additions
and
6 deletions
.gitignore
+
3
−
2
View file @
5a5832aa
.vscode/*
.vscode/settings.json
README.md
README.md
\ No newline at end of file
.vscode/launch.json
\ No newline at end of file
This diff is collapsed.
Click to expand it.
.vscode/settings.json
+
9
−
1
View file @
5a5832aa
...
@@ -8,6 +8,14 @@
...
@@ -8,6 +8,14 @@
"/home/derrentner/.javalib/javafx-sdk-23.0.1/lib/javafx.media.jar"
,
"/home/derrentner/.javalib/javafx-sdk-23.0.1/lib/javafx.media.jar"
,
"/home/derrentner/.javalib/javafx-sdk-23.0.1/lib/javafx.swing.jar"
,
"/home/derrentner/.javalib/javafx-sdk-23.0.1/lib/javafx.swing.jar"
,
"/home/derrentner/.javalib/javafx-sdk-23.0.1/lib/javafx.web.jar"
,
"/home/derrentner/.javalib/javafx-sdk-23.0.1/lib/javafx.web.jar"
,
"/home/derrentner/.javalib/javafx-sdk-23.0.1/lib/javafx-swt.jar"
"/home/derrentner/.javalib/javafx-sdk-23.0.1/lib/javafx-swt.jar"
,
"c:
\\
Users
\\
david
\\
Desktop
\\
swt2
\\
javafx-sdk-23.0.1
\\
lib
\\
javafx.base.jar"
,
"c:
\\
Users
\\
david
\\
Desktop
\\
swt2
\\
javafx-sdk-23.0.1
\\
lib
\\
javafx.controls.jar"
,
"c:
\\
Users
\\
david
\\
Desktop
\\
swt2
\\
javafx-sdk-23.0.1
\\
lib
\\
javafx.fxml.jar"
,
"c:
\\
Users
\\
david
\\
Desktop
\\
swt2
\\
javafx-sdk-23.0.1
\\
lib
\\
javafx.graphics.jar"
,
"c:
\\
Users
\\
david
\\
Desktop
\\
swt2
\\
javafx-sdk-23.0.1
\\
lib
\\
javafx.media.jar"
,
"c:
\\
Users
\\
david
\\
Desktop
\\
swt2
\\
javafx-sdk-23.0.1
\\
lib
\\
javafx.swing.jar"
,
"c:
\\
Users
\\
david
\\
Desktop
\\
swt2
\\
javafx-sdk-23.0.1
\\
lib
\\
javafx.web.jar"
,
"c:
\\
Users
\\
david
\\
Desktop
\\
swt2
\\
javafx-sdk-23.0.1
\\
lib
\\
javafx-swt.jar"
]
]
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
GameUI.java
+
12
−
3
View file @
5a5832aa
...
@@ -7,9 +7,15 @@ import javafx.scene.layout.*;
...
@@ -7,9 +7,15 @@ import javafx.scene.layout.*;
import
javafx.stage.Stage
;
import
javafx.stage.Stage
;
import
java.util.Random
;
import
java.util.Random
;
/**
* This class is an Object that defines the GUI of the application.
*/
public
class
GameUI
extends
Application
{
public
class
GameUI
extends
Application
{
Scene
game
,
winningScene
;
Scene
game
,
winningScene
;
BorderPane
gameBorderPane
,
winningBorderPane
;
BorderPane
gameBorderPane
,
winningBorderPane
;
/**
* Board for the buttons and labels
* */
private
Board
board
=
new
Board
();
private
Board
board
=
new
Board
();
private
Label
playerLabel
=
new
Label
(
"Player X's turn"
);
private
Label
playerLabel
=
new
Label
(
"Player X's turn"
);
private
Label
winnerLabel
=
new
Label
(
"Won"
);
private
Label
winnerLabel
=
new
Label
(
"Won"
);
...
@@ -17,7 +23,9 @@ public class GameUI extends Application{
...
@@ -17,7 +23,9 @@ public class GameUI extends Application{
private
Label
scoreLabelO
=
new
Label
(
"Player O: 0"
);
private
Label
scoreLabelO
=
new
Label
(
"Player O: 0"
);
private
Button
[]
buttons
=
new
Button
[
9
];
private
Button
[]
buttons
=
new
Button
[
9
];
/**Random for Images */
/**
* Random for Images
* */
Random
rnd
=
new
Random
();
Random
rnd
=
new
Random
();
/**
/**
...
@@ -36,12 +44,13 @@ public class GameUI extends Application{
...
@@ -36,12 +44,13 @@ public class GameUI extends Application{
winningBorderPane
=
new
BorderPane
();
winningBorderPane
=
new
BorderPane
();
GridPane
gridPane
=
new
GridPane
();
GridPane
gridPane
=
new
GridPane
();
// loop for the 3x3 board
for
(
int
i
=
0
;
i
<
9
;
i
++){
for
(
int
i
=
0
;
i
<
9
;
i
++){
int
index
=
i
;
int
index
=
i
;
buttons
[
i
]
=
new
Button
();
buttons
[
i
]
=
new
Button
();
buttons
[
i
].
setPrefSize
(
150
,
150
);
buttons
[
i
].
setPrefSize
(
150
,
150
);
buttons
[
i
].
setOnAction
(
e
->
handleTurn
(
index
,
stage
));
buttons
[
i
].
setOnAction
(
e
->
handleTurn
(
index
,
stage
));
//empty image as start icon
String
imageSymbols
=
getClass
().
getResource
(
"/textures/empty.png"
).
toExternalForm
();
String
imageSymbols
=
getClass
().
getResource
(
"/textures/empty.png"
).
toExternalForm
();
Image
image
=
new
Image
(
""
+
imageSymbols
);
Image
image
=
new
Image
(
""
+
imageSymbols
);
ImageView
imageView
=
new
ImageView
(
image
);
ImageView
imageView
=
new
ImageView
(
image
);
...
@@ -138,7 +147,7 @@ public class GameUI extends Application{
...
@@ -138,7 +147,7 @@ public class GameUI extends Application{
board
.
setTileOwner
(
index
,
currentPlayer
);
board
.
setTileOwner
(
index
,
currentPlayer
);
//replace symbols with images
//replace symbols with images
int
i
=
rnd
.
nextInt
(
3
);
int
i
=
rnd
.
nextInt
(
10
);
String
imageSymbols
=
currentPlayer
==
0
?
getClass
().
getResource
(
"/textures/1_"
+
i
+
".png"
).
toExternalForm
()
:
String
imageSymbols
=
currentPlayer
==
0
?
getClass
().
getResource
(
"/textures/1_"
+
i
+
".png"
).
toExternalForm
()
:
getClass
().
getResource
(
"/textures/0_"
+
i
+
".png"
).
toExternalForm
();
getClass
().
getResource
(
"/textures/0_"
+
i
+
".png"
).
toExternalForm
();
Image
image
=
new
Image
(
""
+
imageSymbols
);
Image
image
=
new
Image
(
""
+
imageSymbols
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment