-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAlphaBall.pde
50 lines (39 loc) · 1.12 KB
/
AlphaBall.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
class AlphaBall {
float baseX, baseY = 0;
float radius = 15;
float vel_px_per_sec = 10;
float deltaDistance = 0;
boolean dead = false;
float maxRadius = 25;
float alpha = 45;
float vel_radius_px_per_sec = 10;
float deltaRadius = 0;
float radiusY = 0;
AlphaBall(float initX, float initY, ARect g) {
this.baseX = initX;
this.baseY = initY;
this.radius = 25 * ampsum * 50 ;
this.vel_px_per_sec = random(3, 25);
}
void setPixelPerSec(float PixelPerSec) {
this.deltaDistance = this.vel_px_per_sec/frameRate;
this.deltaRadius = vel_radius_px_per_sec/frameRate;
}
void draw(PGraphics g) {
if (dead)
return;
//g.stroke(color(0,200,0,10));
alpha = 80 + alpha * radius/maxRadius;
g.stroke(colorFromMap(int(baseX), int(baseY), true), alpha + 50 * ampsum);
g.fill(0, 0);
g.ellipse(baseX, baseY, this.radius, this.radius + this.radiusY);
this.baseX += this.deltaDistance;
if (this.baseX > g.width) {
this.dead = true;
}
this.radius = this.radius + deltaRadius;
if (this.radius > maxRadius) {
dead = true;
}
}
}