forked from hoangsonww/Space-Invader-Game-JavaFX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameObject.java
41 lines (29 loc) · 944 Bytes
/
GameObject.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
import javafx.scene.canvas.GraphicsContext;
import javafx.geometry.Bounds;
import javafx.scene.shape.Rectangle;
public abstract class GameObject {
protected double x;
protected double y;
protected double width;
protected double height;
public GameObject(double x, double y, double width, double height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
public abstract void update();
public abstract void render(GraphicsContext gc);
public abstract boolean isDead();
public double getX() {
return x;
}
public double getY() {
return y;
}
public Bounds getBounds() {
return new Rectangle(x - getWidth() / 2, y - getHeight() / 2, getWidth(), getHeight()).getBoundsInLocal();
}
public abstract double getWidth();
public abstract double getHeight();
}