Newer
Older
import java.io.FileInputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import java.awt.image.BufferedImage;
public class Tile extends ImageView{
/**These Values are being set when initialized
*/
int size, posx, posy;
/**The Value of this Integer determines who owns this Tile
/**Random for Images
*
*/
Random rnd = new Random();
/**Paths for the images
*
*/
/**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(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();
* @param owner
*/
public void set_owner(int player){
owner = player;
}
/**Returns the owner
* @return owner
*/
public int get_owner(){
return owner;
}
/**Returns if the Tile-owner is equal to the given Player
* @param owner
*/
public boolean is_owner(int player){
return owner == player;
}
/**Whether this Tile is owned by a Player
public boolean exist_owner(){
return owner > 0;
}