-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTile.java
More file actions
44 lines (30 loc) · 898 Bytes
/
Tile.java
File metadata and controls
44 lines (30 loc) · 898 Bytes
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
package mainPackage;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
public class Tile {
//static stuff
public static Tile[] tiles = new Tile[256]; //holds instance of every tile
public static Tile grassTile = new GrassTile(0); //0 is id for grass tile
public static Tile dirtTile = new DirtTile(1);
public static Tile rockTile = new RockTile(2);
//class
public static final int TILEWIDTH = 64, TILEHEIGHT = 64;
protected BufferedImage texture;
protected final int id;
public Tile(BufferedImage texture, int id) {
this.texture = texture;
this.id = id;
tiles[id] = this;
}
public void tick() {
}
public void render(Graphics g, int x, int y) {
g.drawImage(texture, x, y, TILEWIDTH, TILEHEIGHT, null);
}
public boolean isSolid() {
return false;
}
public int getId() {
return id;
}
}