-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSprite.java
More file actions
41 lines (32 loc) · 830 Bytes
/
Sprite.java
File metadata and controls
41 lines (32 loc) · 830 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.geom.Rectangle2D;
import javax.swing.JPanel;
// Base sprite class with position and size
public class Sprite {
protected JPanel panel;
protected int x;
protected int y;
protected int width;
protected int height;
protected Image image;
public Sprite(JPanel p, int xPos, int yPos, int w, int h) {
panel = p;
x = xPos;
y = yPos;
width = w;
height = h;
image = null;
}
public void draw(Graphics2D g2) {
}
public Rectangle2D.Double getBoundingRectangle() {
return new Rectangle2D.Double(x, y, width, height);
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
}