source: lost-haven/main/Item.java@ a49176d

Last change on this file since a49176d was 8edd04e, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 5 years ago

Make the decompiled game code compile successfully

  • Property mode set to 100644
File size: 1.6 KB
Line 
1package main;
2
3import java.awt.Graphics;
4import java.awt.image.BufferedImage;
5import javax.imageio.ImageIO;
6import java.io.IOException;
7
8public 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}
Note: See TracBrowser for help on using the repository browser.