-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSword.java
More file actions
24 lines (21 loc) · 762 Bytes
/
Sword.java
File metadata and controls
24 lines (21 loc) · 762 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 sword subclass
// this imports the libraries to draw the sword
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 Sword extends Item {
private Image swordGif;
// this is the constructor for the sword class
public Sword(int x, int y) {
super(x, y);
swordGif = Toolkit.getDefaultToolkit().createImage("SWORD.gif");
name = "Sword";
}
// this is the draw method for the sword class
public void draw(Graphics g, int xDiff, int yDiff) {
if (visible) {
g.drawImage(swordGif, super.getX() + xDiff, super.getY() + yDiff, 50, 50, null);
}
}
}