-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bullet.pde
44 lines (37 loc) · 837 Bytes
/
Bullet.pde
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
class Bullet {
float x;
float y;
float angle;
float rotate;
int player;
boolean onHold;
int rad = 5;
int reload = 80;
int reloadCounter = 0;
Bullet(int player) {
rotate = 0;
this.player = player;
}
void moveForward(int speed) {
x += speed * cos(angle);
y += speed * sin(angle);
}
void shoot(float x, float y, float angle) {
onHold = false;
this.x = x;
this.y = y;
this.angle = angle;
}
void hold(int num, int total, float centerX, float centerY) {
reloadCounter = 0;
onHold = true;
float individual = 2*PI / total;
this.x = centerX + 30*cos(individual*num + rotate);
this.y = centerY + 30*sin(individual*num + rotate);
}
void display() {
stroke(255, 255, 255);
fill(255, 255, 255);
ellipse(x, y, rad, rad);
}
}