-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBoss.java
More file actions
100 lines (81 loc) · 1.95 KB
/
Boss.java
File metadata and controls
100 lines (81 loc) · 1.95 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import java.awt.*;
public class Boss extends Alien {
boolean isDead = false;
long alienTime = 200;
long lastAlienTime = 0;
int difficulty = 1;
int health = 400;
int damage;
int x_vel = 3;
public void set(){
setHealth(health);
this.fric = 1;
this.scaleWidth = 6;
this.scaleHeight = 4;
this.barx = -50;
this.bary = 10;
}
public String getImg(){
return "images/alien.gif";
}
public Boss(int x,int y) {
super(x,y);
}
public void update(Space space) {
if (x <= 0) {
x_vel += accel;
} else if (x >= space.WIDTH-getWidth()*6) {
x_vel -= accel;
}
x += x_vel;
x_vel *= fric;
bounds.setLocation(getX(),getY());
if (System.currentTimeMillis() - space.lastAlienTime < space.alienTime){
;
}else {
space.lastAlienTime = System.currentTimeMillis();
for(int i = 0;i < difficulty;i++){
int y = space.gen.nextInt((getHeight()*4));
for(int j = 0;j < difficulty * 3;j++) {
space.aliens.add(new BossGreenie(space.gen.nextInt(getWidth()*6)+getX(),y));
}
}
}
damage = 30 - (difficulty * 5);
if(difficulty == 6) {
damage = 2;
}
for(Bullet bullet : space.bullets) {
if (bounds.intersects(bullet.bounds)){
if(health >= damage) {
health -= damage;
} else {
isDead = true;
space.explosionHappened = true;
space.score += difficulty * 100;
space.bossReached = false;
space.bossReady = false;
}
space.bullets.remove(bullet);
}
}
if(bounds.intersects(space.player.bounds)) {
if(space.player.shieldArmed){
/*if(space.player.shieldTime >= 310){
space.player.shieldTime -= 310;
}*/
space.player.shieldArmed = false;
} else {
if (space.player.health >= 50){
space.player.health -= 50;
}
}
}
}
public void draw(Graphics2D g) {
// Keep this guy alive for everrrr
// Do we really want to though?
if (isDead) return;
super.draw(g);
}
}