68 lines
1.8 KiB
Java
68 lines
1.8 KiB
Java
package dev.kske.minesweeper;
|
|
|
|
import java.awt.image.BufferedImage;
|
|
import java.io.IOException;
|
|
import java.net.URL;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
|
/**
|
|
* Project: <strong>Minesweeper</strong><br>
|
|
* File: <strong>Tile.java</strong><br>
|
|
* Created: <strong>22.03.2019</strong><br>
|
|
* Author: <strong>Kai S. K. Engelbart</strong>
|
|
*/
|
|
public class Tile {
|
|
|
|
private static Map<String, BufferedImage> icons;
|
|
|
|
private boolean mine, flagged, touched;
|
|
|
|
private boolean drawSurroundingMines;
|
|
private int surroundingMines;
|
|
|
|
static {
|
|
icons = new HashMap<>();
|
|
final String[] names = { "Mine2", "Mine4", "Tile", "Tile3" };
|
|
for (String name : names) {
|
|
URL file = Tile.class.getResource(name + ".ico");
|
|
try {
|
|
icons.put(name, ImageIO.read(file));
|
|
} catch (IOException e) {
|
|
System.err.println("Error loading texture: " + name);
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
|
|
public Tile() {
|
|
mine = flagged = touched = drawSurroundingMines = false;
|
|
|
|
surroundingMines = 0;
|
|
}
|
|
|
|
public boolean isMine() { return mine; }
|
|
|
|
public void setMine(boolean mine) { this.mine = mine; }
|
|
|
|
public boolean isFlagged() { return flagged; }
|
|
|
|
public void setFlagged(boolean flagged) { this.flagged = flagged; }
|
|
|
|
public boolean isTouched() { return touched; }
|
|
|
|
public void setTouched(boolean touched) { this.touched = touched; }
|
|
|
|
public boolean isDrawSurroundingMines() { return drawSurroundingMines; }
|
|
|
|
public void setDrawSurroundingMines(boolean drawSurroundingMines) {
|
|
this.drawSurroundingMines = drawSurroundingMines;
|
|
}
|
|
|
|
public int getSurroundingMines() { return surroundingMines; }
|
|
|
|
public void setSurroundingMines(int surroundingMines) { this.surroundingMines = surroundingMines; }
|
|
}
|