-
Notifications
You must be signed in to change notification settings - Fork 1
/
BossObj.java
48 lines (43 loc) · 1.48 KB
/
BossObj.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
47
48
import java.awt.Color;
import java.awt.Image;
import java.awt.Graphics;
import java.awt.Rectangle;
public class BossObj extends GameObj {
public static int basiclife = 10;
public static int life = 10;
int gameLevel = 0;
public BossObj(Image img,int x,int y,int width,int height,double speed, int gameLevel,Planewar frame) {
super(img,x,y,width,height,speed,frame);
this.gameLevel = gameLevel;
BossObj.life = (gameLevel + 1) * 10;
BossObj.basiclife = (gameLevel + 1) * 10;
}
@Override
public void paintSelf(Graphics gImage) {
super.paintSelf(gImage);
if (x > Planewar.width-150 || x < -50) {
speed = -speed;
}
x += speed;
for (ShellObj shellObj : GameUtil.shellObjList) {
if (this.getRec().intersects(shellObj.getRec())) {
shellObj.setX(-100);
shellObj.setY(100);
GameUtil.removeList.add(shellObj);
life--;
}
if (life <= 0) {
GameUtil.removeList.add(this);
Planewar.bossAlive = false;
if(gameLevel == 2) Planewar.currentState = Planewar.GameState.VICTORY;
}
}
gImage.setColor(Color.white);
gImage.fillRect(20,40,100,10);
gImage.setColor(Color.red);
gImage.fillRect(20,40,(life*(100))/basiclife,10);
}
public Rectangle getRec() {
return new Rectangle(x,y,width,height);
}
}