Skip to content
Snippets Groups Projects
Commit 2d12421d authored by Josua Oppermann's avatar Josua Oppermann
Browse files

Tile update

parent 095e23b2
No related branches found
No related tags found
No related merge requests found
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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment