-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBullet.java
More file actions
39 lines (33 loc) · 817 Bytes
/
Bullet.java
File metadata and controls
39 lines (33 loc) · 817 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
/**
* @(#)Bullet.java
*
* Sets up the Player's bullet; contains methods relating to the player's bullet (eg. making it move)
*
* @author
* @version 1.00 2021/11/22
*/
public class Bullet extends Common{
public int bW,bH; //height and width
/********************** Constructors **********************/
public Bullet(){
//isn't created until player shoots so there's no need to set it as invisible
}
public Bullet(int x, int y){
setX(x+18);
setY(y);
bW = 5;
bH = 10;
setVisible(false);
setSpeed(10);
}
/********************** Method **********************/
//move
public void bMove(){
if(getY()>-bH && isVisible()){
setY(getY() - getSpeed());
}
else{
setVisible(false); //stop drawing the bullet when it goes off-screen
}
}
}