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