-
Notifications
You must be signed in to change notification settings - Fork 0
/
BPSpiral.java
45 lines (38 loc) · 1.24 KB
/
BPSpiral.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
package game;
import java.awt.Color;
import java.util.ArrayList;
public class BPSpiral extends BulletPattern
{
protected int numCircle;
protected double offset;
protected double bulletSpeed;
protected double bulletRadius;
protected Color color;
protected int betweenDelay;
public BPSpiral(Player playa, Monster monsta, int numCircle, int numBullets, double bulletSpeed, double bulletRadius, Color color, int betweenDelay, int finalDelay) {
super(playa, monsta, betweenDelay, finalDelay, numBullets);
this.numCircle = numCircle;
this.numBullets = numBullets;
this.bulletSpeed = bulletSpeed;
this.bulletRadius = bulletRadius;
this.color = color;
this.betweenDelay = betweenDelay;
}
public ArrayList<Bullet> bullets()
{
ArrayList<Bullet> bullets = new ArrayList<Bullet>();
if (turn >= (1+betweenDelay)*numBullets || turn % (1+betweenDelay) != 0)
{
turn++;
return bullets;
}
int index = turn/(1+betweenDelay);
double angle = 2 * Math.PI * index / numCircle + offset;
bullets.add(new BulletLinear(width, height, monsta.getX(), monsta.getY(), bulletRadius, 1, color, bulletSpeed * Math.cos(angle), bulletSpeed * Math.sin(angle)));
turn++;
return bullets;
}
public void refresh() {
offset = Math.random()*Math.PI*2;
}
}