-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaser.pde
66 lines (51 loc) · 1.15 KB
/
laser.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
class Laser{
float X;
float Y;
float S = -8; // speed
float P = 1; // power
boolean col = true;
int dir = 1;
int introDirection = -1;
float radius = 5;
Laser (float X,float Y){
this.X = X;
this.Y = Y;
}
void display(){
RenderLaser();
}
void RenderLaser(){
stroke(255);
fill (255);
strokeWeight(P);
line (X,Y,X,Y-10);
//ellipse(X,Y-radius,radius,radius);
}
boolean intheworld() {
return (Y < height) && (Y > 0) && (X > 0) && (X < width);
}
int Move(ArrayList aliens){ // returns score
int score = 0;
Y += S * dir;
for (int i = 0; i<aliens.size();i++){
Alien al = (Alien)aliens.get(i);
if(X>al.aX && X<al.aX+20 && abs((Y-10)-(al.aY+20))<4.5){
al.health-=1;
score = al.getScore();
if (al.health<=0){
sounds.soundrand = ceil(random(0,4));
sounds.killAlienSound(sounds.soundrand);
al.destroy();
al.display();
score = al.getScore();
aliens.remove(al);
alienCount-=1;
}
}
}
return score;
}
void introMove(){
X+=S*introDirection;
}
}