-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTile.java
More file actions
53 lines (38 loc) · 1.2 KB
/
Tile.java
File metadata and controls
53 lines (38 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package tile;
import main.ImageReader;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
public class Tile {
public BufferedImage image;
public boolean collision = false;
public Tile() {
}
public Tile(BufferedImage image) {
this.image = image;
}
public Tile(BufferedImage image, boolean collision) {
this.image = image;
this.collision = collision;
}
public static ArrayList<Tile> getTiles(String folderPath) {
File folder = new File("res/" + folderPath);
File[] files = folder.listFiles();
Tile[] tile = new Tile[files.length];
ArrayList<Tile> tileSet = new ArrayList<>();
try {
String filePath;
for (int i = 0; i < files.length; i++) {
tile[i] = new Tile();
filePath = folderPath + "/tile" + (i+1) + ".png";
System.out.println(filePath);
tile[i].image = ImageReader.readImage(filePath);
tileSet.add( tile[i] );
}
} catch (IOException e) {
throw new RuntimeException(e);
}
return tileSet;
}
}