回答編集履歴
4
見直しキャンペーン中
test
CHANGED
@@ -1,461 +1,228 @@
|
|
1
|
-
1.はカラーモードのせいみたいですね。よくわかっていませんが、
|
1
|
+
1.はカラーモードのせいみたいですね。よくわかっていませんが、↓とすれば表示されました。
|
2
|
-
|
3
|
-
```Processing
|
2
|
+
```Processing
|
4
|
-
|
5
3
|
colorMode(RGB);
|
6
|
-
|
7
4
|
//木
|
8
|
-
|
9
5
|
Tree(30, width/2, height, PI, width/8);
|
10
|
-
|
11
6
|
//地面
|
12
|
-
|
13
7
|
fill(#959592);
|
14
|
-
|
15
8
|
rect(0, 1030, 2000, 50);
|
16
|
-
|
17
9
|
// 戻したほうがいい?
|
18
|
-
|
19
10
|
//colorMode(HSB, 360, 100, 100, 100);
|
20
|
-
|
21
|
-
```
|
11
|
+
```
|
22
|
-
|
23
|
-
とすれば表示されました。
|
24
|
-
|
25
|
-
|
26
12
|
|
27
13
|
2.はここのことでしょうか?
|
28
|
-
|
29
|
-
```Processing
|
14
|
+
```Processing
|
30
|
-
|
31
15
|
particles[i].location.set(width/2.0, height/2.3);
|
32
|
-
|
33
|
-
```
|
16
|
+
```
|
34
|
-
|
35
17
|
こっち??
|
36
|
-
|
37
|
-
```Processing
|
18
|
+
```Processing
|
38
|
-
|
39
19
|
ellipse(location.x, location.y, playerIn, playerIn);
|
40
|
-
|
41
20
|
ellipse(location.x*1.2, location.y, playerIn, playerIn);
|
42
|
-
|
43
21
|
ellipse(location.x/1.3, location.y, playerIn, playerIn);
|
44
|
-
|
45
|
-
```
|
22
|
+
```
|
46
|
-
|
47
|
-
|
48
|
-
|
23
|
+
|
49
|
-
particleは3つでセットのようなので上のことだとして、
|
24
|
+
particleは3つでセットのようなので上のことだとして、こんなんでいいのでしょうか?外している気がします^^;
|
50
|
-
|
51
|
-
```Processing
|
25
|
+
```Processing
|
52
|
-
|
53
26
|
particles[i].location.set(width/2.0-random(-50,50), height/2.3-random(-50,50));
|
54
|
-
|
55
|
-
```
|
27
|
+
```
|
56
|
-
|
28
|
+
|
57
|
-
|
29
|
+
---
|
58
|
-
|
59
|
-
|
60
30
|
|
61
31
|
追記
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
---
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
```Processing
|
32
|
+
```Processing
|
70
|
-
|
71
33
|
import ddf.minim.*;
|
72
|
-
|
73
34
|
import ddf.minim.analysis.*;
|
74
|
-
|
75
35
|
import ddf.minim.effects.*;
|
76
|
-
|
77
36
|
import ddf.minim.signals.*;
|
78
|
-
|
79
37
|
import ddf.minim.spi.*;
|
80
|
-
|
81
38
|
import ddf.minim.ugens.*;
|
82
39
|
|
83
|
-
|
84
|
-
|
85
40
|
Minim minim;
|
86
|
-
|
87
41
|
AudioPlayer player;
|
88
42
|
|
89
|
-
|
90
|
-
|
91
43
|
// パーティクルが増減するので配列からリストに変更
|
92
|
-
|
93
44
|
//int NUM = 10;
|
94
|
-
|
95
45
|
//ParticleVec2[] particles = new ParticleVec2[NUM];
|
96
|
-
|
97
46
|
ArrayList<ParticleVec2> particles = new ArrayList<ParticleVec2>();
|
98
47
|
|
99
|
-
|
100
|
-
|
101
48
|
// 親はとりあえず3つ べたに並べましたが5つとかなら配列で管理するほうがいいでしょうね
|
102
|
-
|
103
49
|
ParticleVec2 parent1 = new ParticleVec2(10);
|
104
|
-
|
105
50
|
ParticleVec2 parent2 = new ParticleVec2(10);
|
106
|
-
|
107
51
|
ParticleVec2 parent3 = new ParticleVec2(10);
|
108
52
|
|
109
|
-
|
110
|
-
|
111
53
|
void setup() {
|
112
|
-
|
113
54
|
fullScreen();
|
114
|
-
|
115
55
|
smooth();
|
116
|
-
|
117
56
|
frameRate(60);
|
118
|
-
|
119
57
|
colorMode(HSB, 360, 100, 100, 100);
|
120
58
|
|
121
|
-
|
122
|
-
|
123
59
|
minim = new Minim(this);
|
124
|
-
|
125
60
|
player = minim.loadFile("Mountain.mp3");
|
126
|
-
|
127
61
|
player.loop();
|
128
62
|
|
129
|
-
|
130
|
-
|
131
63
|
// パーティクルはクリック時に追加するので親だけランダム位置に(あんまりいい位置に来てない気がします 調整してください)
|
132
|
-
|
133
64
|
parent1.location.set(width / 2.0 - random(-50, 50), height / 2 - random(50, 100));
|
134
|
-
|
135
65
|
parent2.location.set(width / 2.0 * 1.2 - random(-50, 50), height / 2 - random(50, 100));
|
136
|
-
|
137
66
|
parent3.location.set(width / 2.0 / 1.3 - random(-50, 50), height / 2 - random(50, 100));
|
138
|
-
|
139
67
|
//for (int i = 0; i < NUM; i++) {
|
140
|
-
|
141
68
|
// particles[i] = new ParticleVec2();
|
142
|
-
|
143
69
|
// particles[i].location.set(width/2.0, height/2.3);
|
144
|
-
|
145
70
|
//}
|
146
|
-
|
147
|
-
}
|
71
|
+
}
|
148
|
-
|
149
|
-
|
150
72
|
|
151
73
|
void draw() {
|
152
|
-
|
153
74
|
fill(0, 31);
|
154
|
-
|
155
75
|
rect(0, 0, width, height);
|
156
|
-
|
157
76
|
noStroke();
|
158
|
-
|
159
77
|
fill(100);
|
160
78
|
|
161
|
-
|
162
|
-
|
163
79
|
// 親の表示 親は動かないのでupdateもbounceOffWallsもしない
|
164
|
-
|
165
80
|
parent1.draw();
|
166
|
-
|
167
81
|
parent2.draw();
|
168
|
-
|
169
82
|
parent3.draw();
|
170
83
|
|
171
|
-
|
172
|
-
|
173
84
|
// 子供の表示
|
174
|
-
|
175
85
|
for (ParticleVec2 p : particles) {
|
176
|
-
|
177
86
|
p.update();
|
178
|
-
|
179
87
|
p.draw();
|
180
|
-
|
181
88
|
p.bounceOffWalls();
|
182
|
-
|
183
|
-
}
|
89
|
+
}
|
184
|
-
|
185
|
-
|
186
90
|
|
187
91
|
colorMode(RGB);
|
188
|
-
|
189
92
|
Tree(30, width / 2, height, PI, width / 8);
|
190
|
-
|
191
93
|
fill(#959592);
|
192
|
-
|
193
94
|
rect(0, 1030, 2000, 50);
|
194
|
-
|
195
|
-
}
|
95
|
+
}
|
196
|
-
|
197
|
-
|
198
|
-
|
199
96
|
|
200
97
|
|
201
98
|
void Tree(float strokeWeight, float x, float y, float rotate, float length) {
|
202
|
-
|
203
99
|
pushMatrix();
|
204
|
-
|
205
100
|
translate(x, y);
|
206
|
-
|
207
101
|
rotate(rotate);
|
208
|
-
|
209
102
|
strokeWeight(strokeWeight);
|
210
|
-
|
211
103
|
stroke(50, 0, 0);
|
212
|
-
|
213
104
|
line(0, 0, 0, length);
|
214
|
-
|
215
105
|
popMatrix();
|
216
|
-
|
217
106
|
if (strokeWeight < 2) return;
|
218
|
-
|
219
107
|
if (random(0, 4) > 3 && strokeWeight < 3) return;
|
220
|
-
|
221
108
|
Tree(strokeWeight * 2 / 3, x - sin(rotate) * length, y + cos(rotate) * length, rotate - PI / 10, length * 2 / 3);
|
222
|
-
|
223
109
|
Tree(strokeWeight * 2 / 3, x - sin(rotate) * length, y + cos(rotate) * length, rotate + PI / 10, length * 2 / 3);
|
224
|
-
|
225
|
-
}
|
110
|
+
}
|
226
|
-
|
227
|
-
|
228
111
|
|
229
112
|
void mouseClicked(MouseEvent e) {
|
230
|
-
|
231
113
|
// とりあえず右クリックでリセット
|
232
|
-
|
233
114
|
if (e.getButton() == RIGHT) {
|
234
|
-
|
235
115
|
particles.clear();
|
236
|
-
|
237
116
|
return;
|
238
|
-
|
239
|
-
}
|
117
|
+
}
|
240
|
-
|
241
|
-
|
242
118
|
|
243
119
|
// 親1の位置にパーティクルを5個追加
|
244
|
-
|
245
120
|
for (int i = 0; i < 5; i++) {
|
246
|
-
|
247
121
|
ParticleVec2 particle = new ParticleVec2(4);
|
248
|
-
|
249
122
|
particle.location.set(parent1.location);
|
250
|
-
|
251
123
|
particles.add(particle);
|
252
|
-
|
253
|
-
}
|
124
|
+
}
|
254
|
-
|
255
125
|
// 親2の位置にパーティクルを5個追加
|
256
|
-
|
257
126
|
for (int i = 0; i < 5; i++) {
|
258
|
-
|
259
127
|
ParticleVec2 particle = new ParticleVec2(4);
|
260
|
-
|
261
128
|
particle.location.set(parent2.location);
|
262
|
-
|
263
129
|
particles.add(particle);
|
264
|
-
|
265
|
-
}
|
130
|
+
}
|
266
|
-
|
267
131
|
// 親3の位置にパーティクルを5個追加
|
268
|
-
|
269
132
|
for (int i = 0; i < 5; i++) {
|
270
|
-
|
271
133
|
ParticleVec2 particle = new ParticleVec2(4);
|
272
|
-
|
273
134
|
particle.location.set(parent3.location);
|
274
|
-
|
275
135
|
particles.add(particle);
|
276
|
-
|
277
|
-
}
|
136
|
+
}
|
278
|
-
|
279
|
-
|
280
137
|
|
281
138
|
//パーティクルの数だけくりかえし
|
282
|
-
|
283
139
|
for (ParticleVec2 p : particles) {
|
284
|
-
|
285
140
|
float angle = random(PI * 2.0);
|
286
|
-
|
287
141
|
float length = random(20);
|
288
|
-
|
289
142
|
float posX = cos(angle) * length;
|
290
|
-
|
291
143
|
float posY = sin(angle) * length;
|
292
|
-
|
293
144
|
p.acceleration.set(posX, posY);
|
294
|
-
|
295
145
|
p.gravity.set(0.0, 0.1);
|
296
|
-
|
297
146
|
p.friction = 0.01;
|
298
|
-
|
299
147
|
PVector force = new PVector(cos(angle) * length, sin(angle) * length);
|
300
|
-
|
301
148
|
p.addForce(force);
|
302
|
-
|
303
|
-
}
|
149
|
+
}
|
304
|
-
|
305
|
-
}
|
150
|
+
}
|
306
|
-
|
307
|
-
|
308
151
|
|
309
152
|
void stop() {
|
310
|
-
|
311
153
|
minim.stop();
|
312
|
-
|
313
154
|
super.stop();
|
314
|
-
|
315
|
-
}
|
155
|
+
}
|
316
|
-
|
317
|
-
|
318
|
-
|
319
156
|
|
320
157
|
|
321
158
|
class ParticleVec2 {
|
322
|
-
|
323
159
|
PVector location;
|
324
|
-
|
325
160
|
PVector velocity;
|
326
|
-
|
327
161
|
PVector acceleration;
|
328
|
-
|
329
162
|
PVector gravity;
|
330
|
-
|
331
163
|
float mass;
|
332
|
-
|
333
164
|
float friction;
|
334
|
-
|
335
165
|
PVector min;
|
336
|
-
|
337
166
|
PVector max;
|
338
|
-
|
339
167
|
float radius;
|
340
168
|
|
341
|
-
|
342
|
-
|
343
169
|
// 親を大きめに表示したかったので、パーティクル半径をコンストラクタで指定 子供が4で親が10にしたが特に根拠はない
|
344
|
-
|
345
170
|
ParticleVec2(float radius) {
|
346
|
-
|
347
171
|
//radius = 4.0;
|
348
|
-
|
349
172
|
this.radius = radius;
|
350
|
-
|
351
173
|
mass = 1.0;
|
352
|
-
|
353
174
|
friction = 0.01;
|
354
|
-
|
355
175
|
location = new PVector(0.0, 0.0);
|
356
|
-
|
357
176
|
velocity = new PVector(0.0, 0.0);
|
358
|
-
|
359
177
|
acceleration = new PVector(0.0, 0.0);
|
360
|
-
|
361
178
|
gravity = new PVector(0.0, 0.0);
|
362
|
-
|
363
179
|
min = new PVector(0.0, 0.0);
|
364
|
-
|
365
180
|
max = new PVector(width, height);
|
366
|
-
|
367
|
-
}
|
181
|
+
}
|
368
|
-
|
369
|
-
|
370
182
|
|
371
183
|
void update() {
|
372
|
-
|
373
184
|
acceleration.add(gravity);
|
374
|
-
|
375
185
|
velocity.add(acceleration);
|
376
|
-
|
377
186
|
velocity.mult(1.0 - friction);
|
378
|
-
|
379
187
|
location.add(velocity);
|
380
|
-
|
381
188
|
acceleration.set(0, 0);
|
382
|
-
|
383
|
-
}
|
189
|
+
}
|
384
|
-
|
385
|
-
|
386
190
|
|
387
191
|
void draw() {
|
388
|
-
|
389
192
|
// 200固定だったのをradiusを考慮するように変更 子供を4にしたので50*4=200で大きさは同じ 親は2.5倍
|
390
|
-
|
391
193
|
//playerIn = player.mix.level()*200;
|
392
|
-
|
393
194
|
float playerIn = player.mix.level() * 50 * radius;
|
394
|
-
|
395
195
|
noStroke();
|
396
|
-
|
397
196
|
fill(random(255), random(255), random(255), 50);
|
398
197
|
|
399
|
-
|
400
|
-
|
401
198
|
// 3つセットにする意味もなくなったのでいっこに
|
402
|
-
|
403
199
|
ellipse(location.x, location.y, playerIn, playerIn);
|
404
|
-
|
405
200
|
//ellipse(location.x*1.2, location.y, playerIn, playerIn);
|
406
|
-
|
407
201
|
//ellipse(location.x/1.3, location.y, playerIn, playerIn);
|
408
|
-
|
409
|
-
}
|
202
|
+
}
|
410
|
-
|
411
|
-
|
412
203
|
|
413
204
|
void bounceOffWalls() {
|
414
|
-
|
415
205
|
if (location.x > max.x) {
|
416
|
-
|
417
206
|
location.x = max.x;
|
418
|
-
|
419
207
|
velocity.x *= -1;
|
420
|
-
|
421
|
-
}
|
208
|
+
}
|
422
|
-
|
423
209
|
if (location.x < min.x) {
|
424
|
-
|
425
210
|
location.x = min.x;
|
426
|
-
|
427
211
|
velocity.x *= -1;
|
428
|
-
|
429
|
-
}
|
212
|
+
}
|
430
|
-
|
431
213
|
if (location.y > max.y) {
|
432
|
-
|
433
214
|
location.y = max.y;
|
434
|
-
|
435
215
|
velocity.y *= -1;
|
436
|
-
|
437
|
-
}
|
216
|
+
}
|
438
|
-
|
439
217
|
if (location.y < min.y) {
|
440
|
-
|
441
218
|
location.y = min.y;
|
442
|
-
|
443
219
|
velocity.y *= -1;
|
444
|
-
|
445
|
-
}
|
220
|
+
}
|
446
|
-
|
447
|
-
}
|
221
|
+
}
|
448
|
-
|
449
|
-
|
450
222
|
|
451
223
|
void addForce(PVector force) {
|
452
|
-
|
453
224
|
force.div(mass);
|
454
|
-
|
455
225
|
acceleration.add(force);
|
456
|
-
|
457
|
-
}
|
226
|
+
}
|
458
|
-
|
459
|
-
}
|
227
|
+
}
|
460
|
-
|
461
|
-
```
|
228
|
+
```
|
3
コード追記
test
CHANGED
@@ -55,3 +55,407 @@
|
|
55
55
|
```
|
56
56
|
|
57
57
|
こんなんでいいのでしょうか?外している気がします^^;
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
追記
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
---
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
```Processing
|
70
|
+
|
71
|
+
import ddf.minim.*;
|
72
|
+
|
73
|
+
import ddf.minim.analysis.*;
|
74
|
+
|
75
|
+
import ddf.minim.effects.*;
|
76
|
+
|
77
|
+
import ddf.minim.signals.*;
|
78
|
+
|
79
|
+
import ddf.minim.spi.*;
|
80
|
+
|
81
|
+
import ddf.minim.ugens.*;
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
Minim minim;
|
86
|
+
|
87
|
+
AudioPlayer player;
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
// パーティクルが増減するので配列からリストに変更
|
92
|
+
|
93
|
+
//int NUM = 10;
|
94
|
+
|
95
|
+
//ParticleVec2[] particles = new ParticleVec2[NUM];
|
96
|
+
|
97
|
+
ArrayList<ParticleVec2> particles = new ArrayList<ParticleVec2>();
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
// 親はとりあえず3つ べたに並べましたが5つとかなら配列で管理するほうがいいでしょうね
|
102
|
+
|
103
|
+
ParticleVec2 parent1 = new ParticleVec2(10);
|
104
|
+
|
105
|
+
ParticleVec2 parent2 = new ParticleVec2(10);
|
106
|
+
|
107
|
+
ParticleVec2 parent3 = new ParticleVec2(10);
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
void setup() {
|
112
|
+
|
113
|
+
fullScreen();
|
114
|
+
|
115
|
+
smooth();
|
116
|
+
|
117
|
+
frameRate(60);
|
118
|
+
|
119
|
+
colorMode(HSB, 360, 100, 100, 100);
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
minim = new Minim(this);
|
124
|
+
|
125
|
+
player = minim.loadFile("Mountain.mp3");
|
126
|
+
|
127
|
+
player.loop();
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
// パーティクルはクリック時に追加するので親だけランダム位置に(あんまりいい位置に来てない気がします 調整してください)
|
132
|
+
|
133
|
+
parent1.location.set(width / 2.0 - random(-50, 50), height / 2 - random(50, 100));
|
134
|
+
|
135
|
+
parent2.location.set(width / 2.0 * 1.2 - random(-50, 50), height / 2 - random(50, 100));
|
136
|
+
|
137
|
+
parent3.location.set(width / 2.0 / 1.3 - random(-50, 50), height / 2 - random(50, 100));
|
138
|
+
|
139
|
+
//for (int i = 0; i < NUM; i++) {
|
140
|
+
|
141
|
+
// particles[i] = new ParticleVec2();
|
142
|
+
|
143
|
+
// particles[i].location.set(width/2.0, height/2.3);
|
144
|
+
|
145
|
+
//}
|
146
|
+
|
147
|
+
}
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
void draw() {
|
152
|
+
|
153
|
+
fill(0, 31);
|
154
|
+
|
155
|
+
rect(0, 0, width, height);
|
156
|
+
|
157
|
+
noStroke();
|
158
|
+
|
159
|
+
fill(100);
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
// 親の表示 親は動かないのでupdateもbounceOffWallsもしない
|
164
|
+
|
165
|
+
parent1.draw();
|
166
|
+
|
167
|
+
parent2.draw();
|
168
|
+
|
169
|
+
parent3.draw();
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
// 子供の表示
|
174
|
+
|
175
|
+
for (ParticleVec2 p : particles) {
|
176
|
+
|
177
|
+
p.update();
|
178
|
+
|
179
|
+
p.draw();
|
180
|
+
|
181
|
+
p.bounceOffWalls();
|
182
|
+
|
183
|
+
}
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
colorMode(RGB);
|
188
|
+
|
189
|
+
Tree(30, width / 2, height, PI, width / 8);
|
190
|
+
|
191
|
+
fill(#959592);
|
192
|
+
|
193
|
+
rect(0, 1030, 2000, 50);
|
194
|
+
|
195
|
+
}
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
void Tree(float strokeWeight, float x, float y, float rotate, float length) {
|
202
|
+
|
203
|
+
pushMatrix();
|
204
|
+
|
205
|
+
translate(x, y);
|
206
|
+
|
207
|
+
rotate(rotate);
|
208
|
+
|
209
|
+
strokeWeight(strokeWeight);
|
210
|
+
|
211
|
+
stroke(50, 0, 0);
|
212
|
+
|
213
|
+
line(0, 0, 0, length);
|
214
|
+
|
215
|
+
popMatrix();
|
216
|
+
|
217
|
+
if (strokeWeight < 2) return;
|
218
|
+
|
219
|
+
if (random(0, 4) > 3 && strokeWeight < 3) return;
|
220
|
+
|
221
|
+
Tree(strokeWeight * 2 / 3, x - sin(rotate) * length, y + cos(rotate) * length, rotate - PI / 10, length * 2 / 3);
|
222
|
+
|
223
|
+
Tree(strokeWeight * 2 / 3, x - sin(rotate) * length, y + cos(rotate) * length, rotate + PI / 10, length * 2 / 3);
|
224
|
+
|
225
|
+
}
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
void mouseClicked(MouseEvent e) {
|
230
|
+
|
231
|
+
// とりあえず右クリックでリセット
|
232
|
+
|
233
|
+
if (e.getButton() == RIGHT) {
|
234
|
+
|
235
|
+
particles.clear();
|
236
|
+
|
237
|
+
return;
|
238
|
+
|
239
|
+
}
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
// 親1の位置にパーティクルを5個追加
|
244
|
+
|
245
|
+
for (int i = 0; i < 5; i++) {
|
246
|
+
|
247
|
+
ParticleVec2 particle = new ParticleVec2(4);
|
248
|
+
|
249
|
+
particle.location.set(parent1.location);
|
250
|
+
|
251
|
+
particles.add(particle);
|
252
|
+
|
253
|
+
}
|
254
|
+
|
255
|
+
// 親2の位置にパーティクルを5個追加
|
256
|
+
|
257
|
+
for (int i = 0; i < 5; i++) {
|
258
|
+
|
259
|
+
ParticleVec2 particle = new ParticleVec2(4);
|
260
|
+
|
261
|
+
particle.location.set(parent2.location);
|
262
|
+
|
263
|
+
particles.add(particle);
|
264
|
+
|
265
|
+
}
|
266
|
+
|
267
|
+
// 親3の位置にパーティクルを5個追加
|
268
|
+
|
269
|
+
for (int i = 0; i < 5; i++) {
|
270
|
+
|
271
|
+
ParticleVec2 particle = new ParticleVec2(4);
|
272
|
+
|
273
|
+
particle.location.set(parent3.location);
|
274
|
+
|
275
|
+
particles.add(particle);
|
276
|
+
|
277
|
+
}
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
//パーティクルの数だけくりかえし
|
282
|
+
|
283
|
+
for (ParticleVec2 p : particles) {
|
284
|
+
|
285
|
+
float angle = random(PI * 2.0);
|
286
|
+
|
287
|
+
float length = random(20);
|
288
|
+
|
289
|
+
float posX = cos(angle) * length;
|
290
|
+
|
291
|
+
float posY = sin(angle) * length;
|
292
|
+
|
293
|
+
p.acceleration.set(posX, posY);
|
294
|
+
|
295
|
+
p.gravity.set(0.0, 0.1);
|
296
|
+
|
297
|
+
p.friction = 0.01;
|
298
|
+
|
299
|
+
PVector force = new PVector(cos(angle) * length, sin(angle) * length);
|
300
|
+
|
301
|
+
p.addForce(force);
|
302
|
+
|
303
|
+
}
|
304
|
+
|
305
|
+
}
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
void stop() {
|
310
|
+
|
311
|
+
minim.stop();
|
312
|
+
|
313
|
+
super.stop();
|
314
|
+
|
315
|
+
}
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
class ParticleVec2 {
|
322
|
+
|
323
|
+
PVector location;
|
324
|
+
|
325
|
+
PVector velocity;
|
326
|
+
|
327
|
+
PVector acceleration;
|
328
|
+
|
329
|
+
PVector gravity;
|
330
|
+
|
331
|
+
float mass;
|
332
|
+
|
333
|
+
float friction;
|
334
|
+
|
335
|
+
PVector min;
|
336
|
+
|
337
|
+
PVector max;
|
338
|
+
|
339
|
+
float radius;
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
// 親を大きめに表示したかったので、パーティクル半径をコンストラクタで指定 子供が4で親が10にしたが特に根拠はない
|
344
|
+
|
345
|
+
ParticleVec2(float radius) {
|
346
|
+
|
347
|
+
//radius = 4.0;
|
348
|
+
|
349
|
+
this.radius = radius;
|
350
|
+
|
351
|
+
mass = 1.0;
|
352
|
+
|
353
|
+
friction = 0.01;
|
354
|
+
|
355
|
+
location = new PVector(0.0, 0.0);
|
356
|
+
|
357
|
+
velocity = new PVector(0.0, 0.0);
|
358
|
+
|
359
|
+
acceleration = new PVector(0.0, 0.0);
|
360
|
+
|
361
|
+
gravity = new PVector(0.0, 0.0);
|
362
|
+
|
363
|
+
min = new PVector(0.0, 0.0);
|
364
|
+
|
365
|
+
max = new PVector(width, height);
|
366
|
+
|
367
|
+
}
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
void update() {
|
372
|
+
|
373
|
+
acceleration.add(gravity);
|
374
|
+
|
375
|
+
velocity.add(acceleration);
|
376
|
+
|
377
|
+
velocity.mult(1.0 - friction);
|
378
|
+
|
379
|
+
location.add(velocity);
|
380
|
+
|
381
|
+
acceleration.set(0, 0);
|
382
|
+
|
383
|
+
}
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
void draw() {
|
388
|
+
|
389
|
+
// 200固定だったのをradiusを考慮するように変更 子供を4にしたので50*4=200で大きさは同じ 親は2.5倍
|
390
|
+
|
391
|
+
//playerIn = player.mix.level()*200;
|
392
|
+
|
393
|
+
float playerIn = player.mix.level() * 50 * radius;
|
394
|
+
|
395
|
+
noStroke();
|
396
|
+
|
397
|
+
fill(random(255), random(255), random(255), 50);
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
// 3つセットにする意味もなくなったのでいっこに
|
402
|
+
|
403
|
+
ellipse(location.x, location.y, playerIn, playerIn);
|
404
|
+
|
405
|
+
//ellipse(location.x*1.2, location.y, playerIn, playerIn);
|
406
|
+
|
407
|
+
//ellipse(location.x/1.3, location.y, playerIn, playerIn);
|
408
|
+
|
409
|
+
}
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
void bounceOffWalls() {
|
414
|
+
|
415
|
+
if (location.x > max.x) {
|
416
|
+
|
417
|
+
location.x = max.x;
|
418
|
+
|
419
|
+
velocity.x *= -1;
|
420
|
+
|
421
|
+
}
|
422
|
+
|
423
|
+
if (location.x < min.x) {
|
424
|
+
|
425
|
+
location.x = min.x;
|
426
|
+
|
427
|
+
velocity.x *= -1;
|
428
|
+
|
429
|
+
}
|
430
|
+
|
431
|
+
if (location.y > max.y) {
|
432
|
+
|
433
|
+
location.y = max.y;
|
434
|
+
|
435
|
+
velocity.y *= -1;
|
436
|
+
|
437
|
+
}
|
438
|
+
|
439
|
+
if (location.y < min.y) {
|
440
|
+
|
441
|
+
location.y = min.y;
|
442
|
+
|
443
|
+
velocity.y *= -1;
|
444
|
+
|
445
|
+
}
|
446
|
+
|
447
|
+
}
|
448
|
+
|
449
|
+
|
450
|
+
|
451
|
+
void addForce(PVector force) {
|
452
|
+
|
453
|
+
force.div(mass);
|
454
|
+
|
455
|
+
acceleration.add(force);
|
456
|
+
|
457
|
+
}
|
458
|
+
|
459
|
+
}
|
460
|
+
|
461
|
+
```
|
2
修正2
test
CHANGED
@@ -24,7 +24,7 @@
|
|
24
24
|
|
25
25
|
|
26
26
|
|
27
|
-
2.は
|
27
|
+
2.はここのことでしょうか?
|
28
28
|
|
29
29
|
```Processing
|
30
30
|
|
@@ -32,7 +32,7 @@
|
|
32
32
|
|
33
33
|
```
|
34
34
|
|
35
|
-
こ
|
35
|
+
こっち??
|
36
36
|
|
37
37
|
```Processing
|
38
38
|
|
@@ -43,8 +43,6 @@
|
|
43
43
|
ellipse(location.x/1.3, location.y, playerIn, playerIn);
|
44
44
|
|
45
45
|
```
|
46
|
-
|
47
|
-
こっち??
|
48
46
|
|
49
47
|
|
50
48
|
|
1
修正
test
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
1.はカラーモードのせいみたいですね。よくわかっていませんが、
|
2
2
|
|
3
3
|
```Processing
|
4
|
+
|
5
|
+
colorMode(RGB);
|
4
6
|
|
5
7
|
//木
|
6
8
|
|
@@ -14,7 +16,7 @@
|
|
14
16
|
|
15
17
|
// 戻したほうがいい?
|
16
18
|
|
17
|
-
colorMode(HSB, 360, 100, 100, 100);
|
19
|
+
//colorMode(HSB, 360, 100, 100, 100);
|
18
20
|
|
19
21
|
```
|
20
22
|
|