-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sprite.java
57 lines (46 loc) · 1.05 KB
/
Sprite.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import java.awt.Image;
import javax.swing.ImageIcon;
import java.net.URL;
public class Sprite{
protected int x;
protected int y;
protected int width;
protected int height;
protected boolean visible;
protected Image image;
public Sprite(int x, int y){
this.x = x;
this.y = y;
visible = true;
}
protected void loadImage(String imageName){
URL url = getClass().getResource(imageName);
ImageIcon ii = new ImageIcon(url);
image = ii.getImage();
}
protected void getImageDimensions(){
width = image.getWidth(null);
height = image.getHeight(null);
}
public Image getImage(){
return image;
}
public int getX(){
return x;
}
public int getY(){
return y;
}
public boolean isVisible(){
return visible;
}
public void setVisible(Boolean visible){
this.visible = visible;
}
public int getWidth(){
return width;
}
public int getHeight(){
return height;
}
}