-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPotion.java
More file actions
24 lines (21 loc) · 770 Bytes
/
Potion.java
File metadata and controls
24 lines (21 loc) · 770 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
// this program holds the code for the potion subclass
// this imports the libraries to draw the potion
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
// this is a subclass of item to use general methods for all items
public class Potion extends Item {
private Image potionGif;
// this is the constructor for the potion class
public Potion(int x, int y) {
super(x, y);
potionGif = Toolkit.getDefaultToolkit().getImage("POTION.gif");
name = "Potion";
}
// this is the draw method for the potion class
public void draw(Graphics g, int xDiff, int yDiff) {
if (visible) {
g.drawImage(potionGif, super.getX()+xDiff, super.getY()+yDiff, 64, 64, null);
}
}
}