-
Notifications
You must be signed in to change notification settings - Fork 1
/
BulletObj.java
29 lines (25 loc) · 991 Bytes
/
BulletObj.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
import java.awt.Image;
import java.awt.Graphics;
import java.awt.Rectangle;
public class BulletObj extends GameObj {
public BulletObj(Image img,int x,int y,int width,int height,double speed,Planewar frame) {
super(img,x,y,width,height,speed,frame);
}
@Override
public void paintSelf(Graphics gImage) {
super.paintSelf(gImage);
y += speed;
if (y > Planewar.height) {
this.x = -300; //this coordinate can't be the same as "shell" and "enemy" (or it'll collide)
this.y = 300;
GameUtil.removeList.add(this);
}
if (/*this.frame.bossObj != null &&*/ this.getRec().intersects(this.frame.planeObj.getRec())) {
Planewar.currentState = Planewar.GameState.GAMEOVER;
Planewar.explode = SoundUtil.playSoundWithVolume(GameUtil.planeExplodeSound, false, Planewar.volume);
}
}
public Rectangle getRec() {
return new Rectangle(x,y,width,height);
}
}