forked from hoangsonww/Space-Invader-Game-JavaFX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PowerUp.java
46 lines (35 loc) · 947 Bytes
/
PowerUp.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
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.paint.Color;
public class PowerUp extends GameObject {
public static final int WIDTH = 20;
public static final int HEIGHT = 20;
private static final double SPEED = 2;
private boolean isDead = false;
public PowerUp(double x, double y) {
super(x, y, WIDTH, HEIGHT);
}
@Override
public void update() {
y += SPEED;
}
@Override
public void render(GraphicsContext gc) {
gc.setFill(Color.GREEN);
gc.fillRect(x - WIDTH / 2, y - HEIGHT / 2, WIDTH, HEIGHT);
}
@Override
public double getWidth() {
return WIDTH;
}
@Override
public double getHeight() {
return HEIGHT;
}
@Override
public boolean isDead() {
return this.isDead;
}
public void setDead(boolean b) {
this.isDead = b;
}
}