-
Notifications
You must be signed in to change notification settings - Fork 0
/
Enemy3.java
88 lines (68 loc) · 1.58 KB
/
Enemy3.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
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
import java.awt.Graphics2D;
import javax.swing.ImageIcon;
//the dragon boss
public class Enemy3 extends Enemyother {
private double x, y, speed;
private static double angle;
private double theta;
private double health;
private double progress;
private static int q;
private static int r;
private static int[][] indicator;
// initializes the dragon
public Enemy3(int q, int r, int x, int y) {
this.q = q;
this.r = r;
this.x = x;
this.y = y;
speed = 20;
angle = 0;
health = 50;
progress = Math.random();
}
// draws the dragon
public void draw(Graphics2D g, ImageIcon[] dragon) {
if (progress < 0.3 && progress > 0.2) {
g.drawImage(dragon[1].getImage(), (int) x - 35, (int) y - 45, 60,
60, null);
} else {
g.drawImage(dragon[0].getImage(), (int) x - 35, (int) y - 45, 60,
60, null);
}
g.drawLine((int) x - 25, (int) y, (int) (x - 25 + 50 * health / 50),
(int) y);
}
// updates the dragon
public void update(double delta, Hextile[][] hextiles, int px, int py) {
angle = Math.atan2(py - y, px - x);
progress = (progress + delta / 20);
if (progress > 1) {
progress = 0;
SpawnAndCast.addEnemies(0);
theta = angle + Math.random() * Math.PI / 2 - Math.PI / 4;
}
}
public void addDamage(int dmg) {
health -= dmg;
}
public int getHP() {
return (int) health;
}
public static int[] getQR() {
int[] QR = { q, r };
return QR;
}
public int getY() {
return (int) y;
}
public int getX() {
return (int) x;
}
public double getProgress() {
return progress;
}
public static double getAngle() {
return angle;
}
}