-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBullet.java
More file actions
44 lines (37 loc) · 841 Bytes
/
Bullet.java
File metadata and controls
44 lines (37 loc) · 841 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
42
43
44
import java.awt.*;
public class Bullet implements IGameConstants{
private int x;
private int y;
private int w;
private int h;
private int speed;
public boolean isVisible;
public Bullet(int x, int dir){
isVisible = true;
this.x = x + (PLAYER_W/2);
this.y = FLOOR;
this.w = this.h = 3;
this.speed = 20 * dir;
}
public Bullet(int x, int y, int dir){
isVisible = true;
this.x = x;
this.y = y;
this.w = this.h = 3;
this.speed = 20 * dir;
}
public void drawBullet(Graphics graphics){
if (isVisible) {
graphics.drawRect(x, y, w, h);
}
}
public void move(){
y += speed;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
}