-
Notifications
You must be signed in to change notification settings - Fork 1
/
PlaneObj.java
40 lines (34 loc) · 1.07 KB
/
PlaneObj.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
import java.awt.Image;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;
public class PlaneObj extends GameObj{
@Override
public Image getImage() {
return super.getImage();
}
public PlaneObj() {
super();
}
public PlaneObj(Image img,int x,int y,int width,int height,double speed,Planewar frame) {
super(img,x,y,width,height,speed,frame);
this.frame.addMouseMotionListener(new MouseAdapter() {
@Override
public void mouseMoved (MouseEvent e) {
PlaneObj.super.x = e.getX() - 11;
PlaneObj.super.y = e.getY() - 16;
}
});
}
@Override
public void paintSelf(Graphics gImage) {
super.paintSelf(gImage);
if (this.frame.bossObj != null && this.getRec().intersects(this.frame.bossObj.getRec())) {
Planewar.currentState = Planewar.GameState.GAMEOVER;
}
}
public Rectangle getRec() {
return new Rectangle(x,y,width,height);
}
}