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
2d12421d
Commit
2d12421d
authored
2 months ago
by
Josua Oppermann
Browse files
Options
Downloads
Patches
Plain Diff
Tile update
parent
095e23b2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tile.java
+37
-9
37 additions, 9 deletions
Tile.java
with
37 additions
and
9 deletions
Tile.java
+
37
−
9
View file @
2d12421d
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.util.Random
;
import
javax.imageio.ImageIO
;
import
javafx.scene.image.Image
;
import
javafx.scene.image.ImageView
;
public
class
Tile
{
import
java.awt.image.BufferedImage
;
public
class
Tile
extends
ImageView
{
/**These Values are being set when initialized
...
...
@@ -10,7 +18,7 @@ public class Tile {
/**The Value of this Integer determines who owns this Tile
* -1 = no one; 0 = Player 1; 1 = Player 2
*/
int
owner
=
0
;
int
owner
=
-
1
;
/**Random for Images
*
...
...
@@ -20,19 +28,39 @@ public class Tile {
/**Paths for the images
*
*/
String
imagePathPlayer
=
"./textures/"
+
owner
+
"_"
+
rnd
.
nextInt
(
3
);
String
imagePathEmpty
=
"./textures/empty"
;
BufferedImage
Image
;
Board
board
;
/**Initializer for Tile Objects
* @param size Sets the Size of the Image
* @param posx Sets the x-Position of the Image
* @param posy Sets the y-Position of the Image
*/
public
Tile
(
int
size
,
int
posx
,
int
posy
){
size
=
this
.
size
;
posx
=
this
.
posx
;
posy
=
this
.
posy
;
public
Tile
(
Board
board
,
int
size
,
int
posx
,
int
posy
){
super
();
setImage
(
new
Image
(
Tile
.
class
.
getClassLoader
().
getResourceAsStream
(
"textures/empty.png"
)));
this
.
size
=
size
;
this
.
posx
=
posx
;
this
.
posy
=
posy
;
setOnMouseClicked
(
e
->
clicked
()
);
this
.
board
=
board
;
//super(Tile.class.getClassLoader().getResourceAsStream("textures/empty.png"));
/*try {
Image = ImageIO.read(Tile.class.getClassLoader().getResourceAsStream("textures/empty.png"));
} catch (IOException e) {
e.printStackTrace();
} //"/textures/" + owner + "_" + rnd.nextInt(3)*/
}
private
void
clicked
()
{
owner
=
board
.
currentPlayer
;
board
.
turnEnd
();
}
/**Lets you set a new owner;
...
...
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