-
Notifications
You must be signed in to change notification settings - Fork 0
/
BPCrossfire.java
44 lines (37 loc) · 1.21 KB
/
BPCrossfire.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
package game;
import java.awt.*;
import java.util.*;
public class BPCrossfire extends BulletPattern
{
protected int numCircle;
protected boolean left;
protected double bulletSpeed;
protected double bulletRadius;
protected Color color;
public BPCrossfire(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;
}
public ArrayList<Bullet> bullets()
{
ArrayList<Bullet> bullets = new ArrayList<Bullet>();
int x = (int) (left?bulletRadius:width-bulletRadius);
int y = (int) (Math.random()*height)/3;
double angle = -Math.atan2(playa.getX()-x, playa.getY()-y)+Math.PI/2;
for (int i = 0; i < numCircle; i++)
{
double speed = bulletSpeed*(i+1)/(numCircle*3) + 2*bulletSpeed/3;
bullets.add(new BulletLinear(width, height, x, y, bulletRadius, 1, color, speed * Math.cos(angle), speed * Math.sin(angle)));
}
left = !left;
return bullets;
}
public void refresh() {
left = Math.random()<0.5;
}
}