-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTileManager.java
More file actions
76 lines (59 loc) · 1.97 KB
/
TileManager.java
File metadata and controls
76 lines (59 loc) · 1.97 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//lala lalai lalai lala lai lai
import java.awt.Graphics2D;
import java.awt.Color;
import javax.imageio.ImageIO;
import java.io.IOException;
import java.awt.image.BufferedImage;
public class TileManager {
GamePanel gp;
Tile[] tile;
int mapTileNum[][];
public TileManager (GamePanel gp) {
this.gp = gp;
tile = new Tile[10];
mapTileNum = new int[20][30];
getTileImage();
}
public void getTileImage() {
try {
tile[0] = new Tile();
tile[0].image = ImageIO.read(getClass().getResourceAsStream("/grass.png"));
tile[1] = new Tile();
tile[1].image = ImageIO.read(getClass().getResourceAsStream("/wall.png"));
tile[2] = new Tile();
tile[2].image = ImageIO.read(getClass().getResourceAsStream("/water.png"));
tile[3] = new Tile();
tile[3].image = ImageIO.read(getClass().getResourceAsStream("/tree.png"));
tile[4] = new Tile();
tile[4].image = ImageIO.read(getClass().getResourceAsStream("/028.png"));
tile[5] = new Tile();
tile[5].image = ImageIO.read(getClass().getResourceAsStream("/029.png"));
tile[6] = new Tile();
tile[6].image = ImageIO.read(getClass().getResourceAsStream("/030.png"));
tile[7] = new Tile();
tile[7].image = ImageIO.read(getClass().getResourceAsStream("/031.png"));
}catch(IOException e) {
e.printStackTrace();
}
}
public void draw(Graphics2D g2) {
// g2.drawImage(tile[2].image, 48, 96, gp.tileSize, gp.tileSize, null);
for (int j = 15; j < 20; j++) {
for (int i = 0; i < 30; i++) {
g2.drawImage(tile[2].image, i * 48, j * 48, gp.tileSize, gp.tileSize, null);
}
}
for (int j = 2; j < 15; j++) {
for (int i = 0; i < 30; i++) {
g2.drawImage(tile[0].image, i * 48, j * 48, gp.tileSize, gp.tileSize, null);
}
}
for (int j = 0; j < 2; j++) {
for (int i = 0; i < 30; i++) {
g2.drawImage(tile[1].image, i * 48, j * 48, gp.tileSize, gp.tileSize, null);
}
}
for (int i = 0; i < 15; i++)
g2.drawImage(tile[1].image, 29 * 48, i * 48, gp.tileSize, gp.tileSize, null);
}
}