|
8
|
1 |
/*
|
|
|
2 |
* This file is part of the TraKERS\Front Processing package.
|
|
|
3 |
*
|
|
|
4 |
* (c) IRI <http://www.iri.centrepompidou.fr/>
|
|
|
5 |
*
|
|
|
6 |
* For the full copyright and license information, please view the LICENSE_FRONT
|
|
|
7 |
* file that was distributed with this source code.
|
|
|
8 |
*/
|
|
|
9 |
|
|
|
10 |
class particle
|
|
|
11 |
{
|
|
|
12 |
float x;
|
|
|
13 |
float y;
|
|
|
14 |
float xvel;
|
|
|
15 |
float yvel;
|
|
|
16 |
float temp;
|
|
|
17 |
int pos;
|
|
|
18 |
|
|
|
19 |
particle(float xIn, float yIn) {
|
|
|
20 |
x = xIn;
|
|
|
21 |
y = yIn;
|
|
|
22 |
}
|
|
|
23 |
|
|
|
24 |
void reposition() {
|
|
|
25 |
x = WIDTH/2+random(-20,20);
|
|
|
26 |
y = random(HEIGHT-10,HEIGHT);
|
|
|
27 |
|
|
|
28 |
xvel = random(-1,1);
|
|
|
29 |
yvel = random(-1,1);
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
void updatepos() {
|
|
|
33 |
int vi = (int)(x/RES);
|
|
|
34 |
int vu = (int)(y/RES);
|
|
|
35 |
|
|
|
36 |
if(vi > 0 && vi < lwidth && vu > 0 && vu < lheight) {
|
|
|
37 |
v[vi][vu].addcolour(2);
|
|
|
38 |
|
|
|
39 |
float ax = (x%RES)/RES;
|
|
|
40 |
float ay = (y%RES)/RES;
|
|
|
41 |
|
|
|
42 |
xvel += (1-ax)*v[vi][vu].xvel*0.05;
|
|
|
43 |
yvel += (1-ay)*v[vi][vu].yvel*0.05;
|
|
|
44 |
|
|
|
45 |
xvel += ax*v[vi+1][vu].xvel*0.05;
|
|
|
46 |
yvel += ax*v[vi+1][vu].yvel*0.05;
|
|
|
47 |
|
|
|
48 |
xvel += ay*v[vi][vu+1].xvel*0.05;
|
|
|
49 |
yvel += ay*v[vi][vu+1].yvel*0.05;
|
|
|
50 |
|
|
|
51 |
v[vi][vu].yvel -= (1-ay)*0.003;
|
|
|
52 |
v[vi+1][vu].yvel -= ax*0.003;
|
|
|
53 |
//v[vi][vu+1].yvel -= ay*0.003;
|
|
|
54 |
|
|
|
55 |
if(v[vi][vu].yvel < 0) v[vi][vu].yvel *= 1.00025;
|
|
|
56 |
|
|
|
57 |
x += xvel;
|
|
|
58 |
y += yvel;
|
|
|
59 |
}
|
|
|
60 |
else {
|
|
|
61 |
reposition();
|
|
|
62 |
}
|
|
|
63 |
if(random(0,400) < 1) reposition();
|
|
|
64 |
|
|
|
65 |
xvel *= 0.6;
|
|
|
66 |
yvel *= 0.6;
|
|
|
67 |
}
|
|
|
68 |
}
|