1 | package main;
|
---|
2 |
|
---|
3 | import java.awt.Graphics;
|
---|
4 | import java.awt.image.BufferedImage;
|
---|
5 | import javax.imageio.ImageIO;
|
---|
6 | import java.io.IOException;
|
---|
7 |
|
---|
8 | public class Item {
|
---|
9 |
|
---|
10 | private String name;
|
---|
11 | private ItemType type;
|
---|
12 | private BufferedImage img;
|
---|
13 | private Point loc;
|
---|
14 | private String description;
|
---|
15 |
|
---|
16 | public Item(String name, ItemType type, String strImg) {
|
---|
17 | this.name = name;
|
---|
18 | this.type = type;
|
---|
19 | this.loc = null;
|
---|
20 | try {
|
---|
21 | this.img = ImageIO.read(getClass().getResource("../images/" + strImg));
|
---|
22 | } catch (IOException ioe) {
|
---|
23 | ioe.printStackTrace();
|
---|
24 | }
|
---|
25 | }
|
---|
26 |
|
---|
27 | public Item(Item copy, Point loc) {
|
---|
28 | this.name = copy.name;
|
---|
29 | this.type = copy.type;
|
---|
30 | this.img = copy.img;
|
---|
31 | this.loc = loc;
|
---|
32 | this.description = copy.description;
|
---|
33 | }
|
---|
34 |
|
---|
35 | public Item copy(Point loc) {
|
---|
36 | return new Item(this, loc);
|
---|
37 | }
|
---|
38 |
|
---|
39 | public BufferedImage getImg() {
|
---|
40 | return this.img;
|
---|
41 | }
|
---|
42 |
|
---|
43 | public String getDescription() {
|
---|
44 | return this.description;
|
---|
45 | }
|
---|
46 |
|
---|
47 | public void setDescription(String description) {
|
---|
48 | this.description = description;
|
---|
49 | }
|
---|
50 |
|
---|
51 | public boolean isRelic() {
|
---|
52 | return (this.type == ItemType.Relic);
|
---|
53 | }
|
---|
54 |
|
---|
55 | public void draw(Graphics g, int playerX, int playerY) {
|
---|
56 | g.drawImage(this.img, 375 + this.loc.getX() - playerX, 275 + this.loc.getY() - playerY, null);
|
---|
57 | }
|
---|
58 |
|
---|
59 | public void drawStatic(Graphics g, int x, int y) {
|
---|
60 | g.drawImage(this.img, x, y, null);
|
---|
61 | }
|
---|
62 |
|
---|
63 | public String getName() {
|
---|
64 | return this.name;
|
---|
65 | }
|
---|
66 |
|
---|
67 | public ItemType getType() {
|
---|
68 | return this.type;
|
---|
69 | }
|
---|
70 |
|
---|
71 | public Point getLoc() {
|
---|
72 | return this.loc;
|
---|
73 | }
|
---|
74 |
|
---|
75 | public void setLoc(Point loc) {
|
---|
76 | this.loc = loc;
|
---|
77 | }
|
---|
78 | }
|
---|