equal
deleted
inserted
replaced
|
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 int pos; |
|
17 |
|
18 particle(float xIn, float yIn) |
|
19 { |
|
20 x = xIn; |
|
21 y = yIn; |
|
22 } |
|
23 |
|
24 void updatepos() |
|
25 { |
|
26 float col1; |
|
27 if(x > 0 && x < WIDTH && y > 0 && y < HEIGHT) |
|
28 { |
|
29 //stroke(#cccccc); |
|
30 //line(x,y,x+xvel,y+yvel); |
|
31 int vi = (int)(x/RES); |
|
32 int vu = (int)(y/RES); |
|
33 vsquare o = v[vi][vu]; |
|
34 //xvel += o.xvel*0.05; |
|
35 //yvel += o.yvel*0.05; |
|
36 |
|
37 float ax = (x%RES)/RES; |
|
38 float ay = (y%RES)/RES; |
|
39 |
|
40 xvel += (1-ax)*v[vi][vu].xvel*0.05; |
|
41 yvel += (1-ay)*v[vi][vu].yvel*0.05; |
|
42 |
|
43 xvel += ax*v[vi+1][vu].xvel*0.05; |
|
44 yvel += ax*v[vi+1][vu].yvel*0.05; |
|
45 |
|
46 xvel += ay*v[vi][vu+1].xvel*0.05; |
|
47 yvel += ay*v[vi][vu+1].yvel*0.05; |
|
48 |
|
49 o.col += 4; |
|
50 |
|
51 x += xvel; |
|
52 y += yvel; |
|
53 } |
|
54 else |
|
55 { |
|
56 x = random(0,WIDTH); |
|
57 y = random(0,HEIGHT); |
|
58 xvel = 0; |
|
59 yvel = 0; |
|
60 } |
|
61 |
|
62 xvel *= 0.5; |
|
63 yvel *= 0.5; |
|
64 } |
|
65 } |