-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnitity.java
More file actions
41 lines (29 loc) · 822 Bytes
/
Copy pathEnitity.java
File metadata and controls
41 lines (29 loc) · 822 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.Color;
import java.awt.Graphics;
import java.awt.geom.Rectangle2D;
public abstract class Enitity {
protected float x, y;
protected int width, height;
protected Rectangle2D.Float hitbox;
public Enitity(float x, float y, int width, int height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
protected void drawHitbox(Graphics g) {
// For debugging the hitbox
g.setColor(Color.PINK);
g.drawRect((int) hitbox.x, (int) hitbox.y, (int) hitbox.width, (int) hitbox.height);
}
protected void initHitbox(float x, float y, float width, float height) {
hitbox = new Rectangle2D.Float(x, y, width, height);
}
// protected void updateHitbox() {
// hitbox.x = (int) x;
// hitbox.y = (int) y;
// }
public Rectangle2D.Float getHitbox() {
return hitbox;
}
}