forked from skooter500/YASC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLazer.pde
44 lines (38 loc) · 807 Bytes
/
Lazer.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 Lazer extends GameObject
{
float aliveFor = 0;
float toLive;
Lazer()
{
w = 5.0f;
h = 5.0f;
mass = 0.2f;
speed = 300.0f;
toLive = 3.0f;
}
void update()
{
aliveFor += timeDelta;
if (aliveFor > toLive)
{
alive = false;
}
integrate();
wrap();
theta = velocity.heading() + HALF_PI;
force.setMag(0);
look.x = sin(theta);
look.y = -cos(theta);
}
void draw()
{
pushMatrix();
translate(position.x, position.y);
rotate(theta);
scale(scaleF);
float alpha = (1.0f - aliveFor / toLive) * 2000.0f;
stroke(red(colour), green(colour), blue(colour), (int)alpha);
line(0, - h / 2.0f, 0, h / 2.0f);
popMatrix();
}
}