-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStar.pde
More file actions
48 lines (39 loc) · 764 Bytes
/
Star.pde
File metadata and controls
48 lines (39 loc) · 764 Bytes
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
class Star {
//position
float x;
float y;
float z;
//previous position
float px;
float py;
float pz;
Star() {
x=random(-width, width);
y=random(-height, height);
z=random(width);
px=z;
}
void update() {
z=z-speed;
if (z < 20)
{
z=width;
x=random(-width, width);
y=random(-height, height);
pz=z;
}
}
void show() {
fill(255);
noStroke();
float sx = map(x / z, 0, 1, 0, width/2);
float sy = map(y / z, 0, 1, 0, height/2);
//float r = map(z, 0, width/2, 16, 0);
//ellipse(sx, sy, r, r);
float px = map(x / pz, 0, 1, 0, width/2);
float py = map(y / pz, 0, 1, 0, height/2);
pz=z;
stroke(255);
line(px, py, sx, sy);
}
}