-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathItem.pde
55 lines (50 loc) · 1.52 KB
/
Item.pde
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
class Item {
Block block;
Tool tool;
int amount;
public Item(Block block, int amount) {
this.block = block;
this.amount = amount;
}
public Item(Tool tool, int amount) {
this.tool = tool;
this.amount = amount;
}
public void display(int x, int y, int size) {
if (block == null) {
tool.display(x, y, size - 20);
if (tool.ttype == Tools.STICK) {
textSize(size);
fill(0);
text(amount, x + size / 2, y + size - 25);
}
} else {
block.display(x, y, size - 20);
textSize(size);
fill(0);
text(amount, x + size / 2, y + size - 25);
}
}
public void regDisplay(int x, int y, int size) {
if (block == null) {
tool.display(x, y, size);
} else {
block.display(x, y, size);
textSize(size);
fill(0);
text(amount, x + size / 2, y + size - 5);
}
}
public String toString() {
if (block == null && tool != null) {
return "TOOL";
} else if (tool == null && block != null) {
return "BLOCK";
}
return "null";
}
//with block.btype.toString()
//, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,
//with BLOCK
//, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,, null,
}