質問編集履歴
5
test
CHANGED
File without changes
|
test
CHANGED
@@ -228,7 +228,11 @@
|
|
228
228
|
|
229
229
|
image(img[array[4][5]], width/2+196,height/2+300,100,100);
|
230
230
|
|
231
|
+
}
|
232
|
+
|
233
|
+
|
234
|
+
|
231
|
-
```
|
235
|
+
```
|
232
236
|
|
233
237
|
|
234
238
|
|
@@ -348,7 +352,11 @@
|
|
348
352
|
|
349
353
|
}
|
350
354
|
|
355
|
+
}
|
356
|
+
|
357
|
+
|
358
|
+
|
351
|
-
```
|
359
|
+
```
|
352
360
|
|
353
361
|
|
354
362
|
|
4
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,9 +24,9 @@
|
|
24
24
|
|
25
25
|
```Processing
|
26
26
|
|
27
|
-
|
27
|
+
|
28
|
-
|
28
|
+
|
29
|
-
|
29
|
+
PImage[] img=new PImage[6];
|
30
30
|
|
31
31
|
boolean f;
|
32
32
|
|
@@ -228,7 +228,7 @@
|
|
228
228
|
|
229
229
|
image(img[array[4][5]], width/2+196,height/2+300,100,100);
|
230
230
|
|
231
|
-
}
|
231
|
+
```}
|
232
232
|
|
233
233
|
|
234
234
|
|
@@ -244,6 +244,8 @@
|
|
244
244
|
|
245
245
|
|
246
246
|
|
247
|
+
```
|
248
|
+
|
247
249
|
int[][] picIdx;
|
248
250
|
|
249
251
|
PImage[] pic;
|
@@ -346,7 +348,7 @@
|
|
346
348
|
|
347
349
|
}
|
348
350
|
|
349
|
-
}
|
351
|
+
```}
|
350
352
|
|
351
353
|
|
352
354
|
|
3
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,7 +22,11 @@
|
|
22
22
|
|
23
23
|
|
24
24
|
|
25
|
+
```Processing
|
26
|
+
|
27
|
+
コード
|
28
|
+
|
25
|
-
PImage[] img=new PImage[6];
|
29
|
+
```PImage[] img=new PImage[6];
|
26
30
|
|
27
31
|
boolean f;
|
28
32
|
|
2
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,6 +32,220 @@
|
|
32
32
|
|
33
33
|
int stick;
|
34
34
|
|
35
|
+
int xx, yy;
|
36
|
+
|
37
|
+
int dx;
|
38
|
+
|
39
|
+
int dy;
|
40
|
+
|
41
|
+
int [][] array;
|
42
|
+
|
43
|
+
void setup(){
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
size(800,1000);
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
img[0]=loadImage("heart.jpg");
|
54
|
+
|
55
|
+
img[1]=loadImage("triangle.jpg");
|
56
|
+
|
57
|
+
img[2]=loadImage("clober.jpg");
|
58
|
+
|
59
|
+
img[3]=loadImage("dia.jpg");
|
60
|
+
|
61
|
+
img[4]=loadImage("spead.jpg");
|
62
|
+
|
63
|
+
img[5]=loadImage("moon.jpg");
|
64
|
+
|
65
|
+
f = false;
|
66
|
+
|
67
|
+
array = new int[5][6];
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
void draw(){
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
if( ! f ) {
|
80
|
+
|
81
|
+
for( int i =0; i<5; i++){
|
82
|
+
|
83
|
+
for( int j = 0; j<6; j++){
|
84
|
+
|
85
|
+
array[i][j] = (int)random(0,5);
|
86
|
+
|
87
|
+
while( j > 0 && array[ i ][ j ] == array[ i ][ j - 1 ] )
|
88
|
+
|
89
|
+
array[i][j] = (int)random(0,5);
|
90
|
+
|
91
|
+
while( i > 0 && array[ i ][ j ] == array[ i - 1 ][ j ] )
|
92
|
+
|
93
|
+
array[i][j] = (int)random(0,5);
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
f = ( frameCount >= 1 );
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
if (stick!=0) {
|
108
|
+
|
109
|
+
image(pic[stick], mouseX-dx, mouseY-dy);
|
110
|
+
|
111
|
+
}
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
void mousePressed() {
|
118
|
+
|
119
|
+
int x=mouseX/W;
|
120
|
+
|
121
|
+
int y=mouseY/H;
|
122
|
+
|
123
|
+
dx=mouseX%W;
|
124
|
+
|
125
|
+
dy=mouseY%H;
|
126
|
+
|
127
|
+
if (stick==0) {
|
128
|
+
|
129
|
+
xx=x;
|
130
|
+
|
131
|
+
yy=y;
|
132
|
+
|
133
|
+
stick=picIdx[y][x];
|
134
|
+
|
135
|
+
picIdx[y][x]=0;
|
136
|
+
|
137
|
+
} else {
|
138
|
+
|
139
|
+
picIdx[yy][xx]=picIdx[y][x];
|
140
|
+
|
141
|
+
picIdx[y][x]=stick;
|
142
|
+
|
143
|
+
stick=0;
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
}
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
image(img[array[0][0]], width/2-304,height/2-100,100,100);
|
152
|
+
|
153
|
+
image(img[array[0][1]], width/2-204,height/2-100,100,100);
|
154
|
+
|
155
|
+
image(img[array[0][2]], width/2-104,height/2-100,100,100);
|
156
|
+
|
157
|
+
image(img[array[0][3]], width/2-4,height/2-100,100,100);
|
158
|
+
|
159
|
+
image(img[array[0][4]], width/2+96,height/2-100,100,100);
|
160
|
+
|
161
|
+
image(img[array[0][5]], width/2+196,height/2-100,100,100);
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
image(img[array[1][0]], width/2-304,height/2,100,100);
|
168
|
+
|
169
|
+
image(img[array[1][1]], width/2-204,height/2,100,100);
|
170
|
+
|
171
|
+
image(img[array[1][2]], width/2-104,height/2,100,100);
|
172
|
+
|
173
|
+
image(img[array[1][3]], width/2-4,height/2,100,100);
|
174
|
+
|
175
|
+
image(img[array[1][4]], width/2+96,height/2,100,100);
|
176
|
+
|
177
|
+
image(img[array[1][5]], width/2+196,height/2,100,100);
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
image(img[array[2][0]], width/2-304,height/2+100,100,100);
|
184
|
+
|
185
|
+
image(img[array[2][1]], width/2-204,height/2+100,100,100);
|
186
|
+
|
187
|
+
image(img[array[2][2]], width/2-104,height/2+100,100,100);
|
188
|
+
|
189
|
+
image(img[array[2][3]], width/2-4,height/2+100,100,100);
|
190
|
+
|
191
|
+
image(img[array[2][4]], width/2+96,height/2+100,100,100);
|
192
|
+
|
193
|
+
image(img[array[2][5]], width/2+196,height/2+100,100,100);
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
image(img[array[3][0]], width/2-304,height/2+200,100,100);
|
200
|
+
|
201
|
+
image(img[array[3][1]], width/2-204,height/2+200,100,100);
|
202
|
+
|
203
|
+
image(img[array[3][2]], width/2-104,height/2+200,100,100);
|
204
|
+
|
205
|
+
image(img[array[3][3]], width/2-4,height/2+200,100,100);
|
206
|
+
|
207
|
+
image(img[array[3][4]], width/2+96,height/2+200,100,100);
|
208
|
+
|
209
|
+
image(img[array[3][5]], width/2+196,height/2+200,100,100);
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
image(img[array[4][0]], width/2-304,height/2+300,100,100);
|
216
|
+
|
217
|
+
image(img[array[4][1]], width/2-204,height/2+300,100,100);
|
218
|
+
|
219
|
+
image(img[array[4][2]], width/2-104,height/2+300,100,100);
|
220
|
+
|
221
|
+
image(img[array[4][3]], width/2-4,height/2+300,100,100);
|
222
|
+
|
223
|
+
image(img[array[4][4]], width/2+96,height/2+300,100,100);
|
224
|
+
|
225
|
+
image(img[array[4][5]], width/2+196,height/2+300,100,100);
|
226
|
+
|
227
|
+
}
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
### エラー
|
232
|
+
|
233
|
+
対応してない部分が多いのでエラーが多発しております。
|
234
|
+
|
235
|
+
(サイズの差、座標位置etc)
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
### 参考にしたコード
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
int[][] picIdx;
|
244
|
+
|
245
|
+
PImage[] pic;
|
246
|
+
|
247
|
+
int stick;
|
248
|
+
|
35
249
|
final int W=64;
|
36
250
|
|
37
251
|
final int H=64;
|
@@ -42,90 +256,46 @@
|
|
42
256
|
|
43
257
|
int dy;
|
44
258
|
|
45
|
-
|
259
|
+
|
46
|
-
|
260
|
+
|
47
|
-
void setup(){
|
261
|
+
void setup() {
|
48
|
-
|
49
|
-
|
50
|
-
|
262
|
+
|
51
|
-
size(8
|
263
|
+
size(384, 320);
|
52
|
-
|
53
|
-
|
54
|
-
|
264
|
+
|
55
|
-
in
|
265
|
+
pic=new PImage[5];
|
266
|
+
|
56
|
-
|
267
|
+
pic[0]=get(0, 0, 64, 64);
|
268
|
+
|
57
|
-
|
269
|
+
PImage img=loadImage("https://photoshopvip.net/wp-content/uploads/2014/06/BALLICONS.jpg");
|
58
|
-
|
270
|
+
|
59
|
-
|
271
|
+
for (int i=1; i<5; i++) {
|
60
|
-
|
61
|
-
|
272
|
+
|
62
|
-
|
63
|
-
|
273
|
+
pic[i]=img.get(12+77*1, 15+77*i, 64, 64);
|
64
|
-
|
274
|
+
|
65
|
-
|
275
|
+
}
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
276
|
+
|
72
|
-
|
73
|
-
img[1]=loadImage("triangle.jpg");
|
74
|
-
|
75
|
-
img[2]=loadImage("clober.jpg");
|
76
|
-
|
77
|
-
img[3]=loadImage("dia.jpg");
|
78
|
-
|
79
|
-
img[4]=loadImage("spead.jpg");
|
80
|
-
|
81
|
-
img[5]=loadImage("moon.jpg");
|
82
|
-
|
83
|
-
f = false;
|
84
|
-
|
85
|
-
|
277
|
+
picIdx=new int[5][6];
|
86
|
-
|
87
|
-
}
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
void draw(){
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
if( ! f ) {
|
98
|
-
|
99
|
-
for( int i =0; i<5; i++){
|
100
|
-
|
101
|
-
for( int j = 0; j<6; j++){
|
102
|
-
|
103
|
-
array[i][j] = (int)random(0,5);
|
104
|
-
|
105
|
-
while( j > 0 && array[ i ][ j ] == array[ i ][ j - 1 ] )
|
106
|
-
|
107
|
-
array[i][j] = (int)random(0,5);
|
108
|
-
|
109
|
-
while( i > 0 && array[ i ][ j ] == array[ i - 1 ][ j ] )
|
110
|
-
|
111
|
-
array[i][j] = (int)random(0,5);
|
112
|
-
|
113
|
-
}
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
}
|
118
|
-
|
119
|
-
f = ( frameCount >= 1 );
|
120
|
-
|
121
|
-
}
|
122
|
-
|
123
|
-
|
124
278
|
|
125
279
|
for (int i=0; i<5; i++) {
|
126
280
|
|
127
281
|
for (int j=0; j<6; j++) {
|
128
282
|
|
283
|
+
picIdx[i][j]=int(random(4)+1);
|
284
|
+
|
285
|
+
}
|
286
|
+
|
287
|
+
}
|
288
|
+
|
289
|
+
}
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
void draw() {
|
294
|
+
|
295
|
+
for (int i=0; i<5; i++) {
|
296
|
+
|
297
|
+
for (int j=0; j<6; j++) {
|
298
|
+
|
129
299
|
image(pic[picIdx[i][j]], j*64, i*64);
|
130
300
|
|
131
301
|
}
|
@@ -176,190 +346,6 @@
|
|
176
346
|
|
177
347
|
|
178
348
|
|
179
|
-
image(img[array[0][0]], width/2-304,height/2-100,100,100);
|
180
|
-
|
181
|
-
image(img[array[0][1]], width/2-204,height/2-100,100,100);
|
182
|
-
|
183
|
-
image(img[array[0][2]], width/2-104,height/2-100,100,100);
|
184
|
-
|
185
|
-
image(img[array[0][3]], width/2-4,height/2-100,100,100);
|
186
|
-
|
187
|
-
image(img[array[0][4]], width/2+96,height/2-100,100,100);
|
188
|
-
|
189
|
-
image(img[array[0][5]], width/2+196,height/2-100,100,100);
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
image(img[array[1][0]], width/2-304,height/2,100,100);
|
196
|
-
|
197
|
-
image(img[array[1][1]], width/2-204,height/2,100,100);
|
198
|
-
|
199
|
-
image(img[array[1][2]], width/2-104,height/2,100,100);
|
200
|
-
|
201
|
-
image(img[array[1][3]], width/2-4,height/2,100,100);
|
202
|
-
|
203
|
-
image(img[array[1][4]], width/2+96,height/2,100,100);
|
204
|
-
|
205
|
-
image(img[array[1][5]], width/2+196,height/2,100,100);
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
image(img[array[2][0]], width/2-304,height/2+100,100,100);
|
212
|
-
|
213
|
-
image(img[array[2][1]], width/2-204,height/2+100,100,100);
|
214
|
-
|
215
|
-
image(img[array[2][2]], width/2-104,height/2+100,100,100);
|
216
|
-
|
217
|
-
image(img[array[2][3]], width/2-4,height/2+100,100,100);
|
218
|
-
|
219
|
-
image(img[array[2][4]], width/2+96,height/2+100,100,100);
|
220
|
-
|
221
|
-
image(img[array[2][5]], width/2+196,height/2+100,100,100);
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
image(img[array[3][0]], width/2-304,height/2+200,100,100);
|
228
|
-
|
229
|
-
image(img[array[3][1]], width/2-204,height/2+200,100,100);
|
230
|
-
|
231
|
-
image(img[array[3][2]], width/2-104,height/2+200,100,100);
|
232
|
-
|
233
|
-
image(img[array[3][3]], width/2-4,height/2+200,100,100);
|
234
|
-
|
235
|
-
image(img[array[3][4]], width/2+96,height/2+200,100,100);
|
236
|
-
|
237
|
-
image(img[array[3][5]], width/2+196,height/2+200,100,100);
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
image(img[array[4][0]], width/2-304,height/2+300,100,100);
|
244
|
-
|
245
|
-
image(img[array[4][1]], width/2-204,height/2+300,100,100);
|
246
|
-
|
247
|
-
image(img[array[4][2]], width/2-104,height/2+300,100,100);
|
248
|
-
|
249
|
-
image(img[array[4][3]], width/2-4,height/2+300,100,100);
|
250
|
-
|
251
|
-
image(img[array[4][4]], width/2+96,height/2+300,100,100);
|
252
|
-
|
253
|
-
image(img[array[4][5]], width/2+196,height/2+300,100,100);
|
254
|
-
|
255
|
-
}
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
###
|
349
|
+
### 補足
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
350
|
+
|
264
|
-
|
265
|
-
PImage[] pic;
|
266
|
-
|
267
|
-
int stick;
|
268
|
-
|
269
|
-
final int W=64;
|
270
|
-
|
271
|
-
final int H=64;
|
272
|
-
|
273
|
-
int xx, yy;
|
274
|
-
|
275
|
-
int dx;
|
276
|
-
|
277
|
-
int dy;
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
void setup() {
|
282
|
-
|
283
|
-
size(384, 320);
|
284
|
-
|
285
|
-
pic=new PImage[5];
|
286
|
-
|
287
|
-
pic[0]=get(0, 0, 64, 64);
|
288
|
-
|
289
|
-
|
351
|
+
エラーが沢山出ているのは対応してない部分が多いので当たり前だろ!と思うかもしれませんが、進まないまま日にちばかり経ってしまったので、手助けをよろしくお願いいたします。
|
290
|
-
|
291
|
-
for (int i=1; i<5; i++) {
|
292
|
-
|
293
|
-
pic[i]=img.get(12+77*1, 15+77*i, 64, 64);
|
294
|
-
|
295
|
-
}
|
296
|
-
|
297
|
-
picIdx=new int[5][6];
|
298
|
-
|
299
|
-
for (int i=0; i<5; i++) {
|
300
|
-
|
301
|
-
for (int j=0; j<6; j++) {
|
302
|
-
|
303
|
-
picIdx[i][j]=int(random(4)+1);
|
304
|
-
|
305
|
-
}
|
306
|
-
|
307
|
-
}
|
308
|
-
|
309
|
-
}
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
void draw() {
|
314
|
-
|
315
|
-
for (int i=0; i<5; i++) {
|
316
|
-
|
317
|
-
for (int j=0; j<6; j++) {
|
318
|
-
|
319
|
-
image(pic[picIdx[i][j]], j*64, i*64);
|
320
|
-
|
321
|
-
}
|
322
|
-
|
323
|
-
}
|
324
|
-
|
325
|
-
if (stick!=0) {
|
326
|
-
|
327
|
-
image(pic[stick], mouseX-dx, mouseY-dy);
|
328
|
-
|
329
|
-
}
|
330
|
-
|
331
|
-
}
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
void mousePressed() {
|
336
|
-
|
337
|
-
int x=mouseX/W;
|
338
|
-
|
339
|
-
int y=mouseY/H;
|
340
|
-
|
341
|
-
dx=mouseX%W;
|
342
|
-
|
343
|
-
dy=mouseY%H;
|
344
|
-
|
345
|
-
if (stick==0) {
|
346
|
-
|
347
|
-
xx=x;
|
348
|
-
|
349
|
-
yy=y;
|
350
|
-
|
351
|
-
stick=picIdx[y][x];
|
352
|
-
|
353
|
-
picIdx[y][x]=0;
|
354
|
-
|
355
|
-
} else {
|
356
|
-
|
357
|
-
picIdx[yy][xx]=picIdx[y][x];
|
358
|
-
|
359
|
-
picIdx[y][x]=stick;
|
360
|
-
|
361
|
-
stick=0;
|
362
|
-
|
363
|
-
}
|
364
|
-
|
365
|
-
}
|
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,11 +18,7 @@
|
|
18
18
|
|
19
19
|
|
20
20
|
|
21
|
-
|
21
|
+
参考になるコートがあったので、自分のものに当てはめてみようとしたのですが、エラーが沢山出て(対応してない部分が多いので当たり前かもしれない)、進め方がわからなくなりました。
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
しかし2次元配列をどうListに入れれば良いかも、その先のことも調べてもなかなか上手く行きません。
|
26
22
|
|
27
23
|
|
28
24
|
|
@@ -30,7 +26,21 @@
|
|
30
26
|
|
31
27
|
boolean f;
|
32
28
|
|
33
|
-
|
29
|
+
int[][] picIdx;
|
30
|
+
|
31
|
+
PImage[] pic;
|
32
|
+
|
33
|
+
int stick;
|
34
|
+
|
35
|
+
final int W=64;
|
36
|
+
|
37
|
+
final int H=64;
|
38
|
+
|
39
|
+
int xx, yy;
|
40
|
+
|
41
|
+
int dx;
|
42
|
+
|
43
|
+
int dy;
|
34
44
|
|
35
45
|
int [][] array;
|
36
46
|
|
@@ -42,6 +52,20 @@
|
|
42
52
|
|
43
53
|
|
44
54
|
|
55
|
+
int k;
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
for(k=0; k < height; k++){
|
60
|
+
|
61
|
+
stroke(k,160,180);
|
62
|
+
|
63
|
+
line(0, k, width,k);
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
|
68
|
+
|
45
69
|
|
46
70
|
|
47
71
|
img[0]=loadImage("heart.jpg");
|
@@ -88,15 +112,69 @@
|
|
88
112
|
|
89
113
|
}
|
90
114
|
|
115
|
+
|
116
|
+
|
91
117
|
}
|
92
118
|
|
93
119
|
f = ( frameCount >= 1 );
|
94
120
|
|
95
121
|
}
|
96
122
|
|
123
|
+
|
124
|
+
|
97
|
-
|
125
|
+
for (int i=0; i<5; i++) {
|
126
|
+
|
98
|
-
|
127
|
+
for (int j=0; j<6; j++) {
|
128
|
+
|
99
|
-
|
129
|
+
image(pic[picIdx[i][j]], j*64, i*64);
|
130
|
+
|
131
|
+
}
|
132
|
+
|
133
|
+
}
|
134
|
+
|
135
|
+
if (stick!=0) {
|
136
|
+
|
137
|
+
image(pic[stick], mouseX-dx, mouseY-dy);
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
}
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
void mousePressed() {
|
146
|
+
|
147
|
+
int x=mouseX/W;
|
148
|
+
|
149
|
+
int y=mouseY/H;
|
150
|
+
|
151
|
+
dx=mouseX%W;
|
152
|
+
|
153
|
+
dy=mouseY%H;
|
154
|
+
|
155
|
+
if (stick==0) {
|
156
|
+
|
157
|
+
xx=x;
|
158
|
+
|
159
|
+
yy=y;
|
160
|
+
|
161
|
+
stick=picIdx[y][x];
|
162
|
+
|
163
|
+
picIdx[y][x]=0;
|
164
|
+
|
165
|
+
} else {
|
166
|
+
|
167
|
+
picIdx[yy][xx]=picIdx[y][x];
|
168
|
+
|
169
|
+
picIdx[y][x]=stick;
|
170
|
+
|
171
|
+
stick=0;
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
}
|
176
|
+
|
177
|
+
|
100
178
|
|
101
179
|
image(img[array[0][0]], width/2-304,height/2-100,100,100);
|
102
180
|
|
@@ -174,50 +252,114 @@
|
|
174
252
|
|
175
253
|
image(img[array[4][5]], width/2+196,height/2+300,100,100);
|
176
254
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
(
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
255
|
+
}
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
### 参考にしたコード
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
int[][] picIdx;
|
264
|
+
|
265
|
+
PImage[] pic;
|
266
|
+
|
267
|
+
int stick;
|
268
|
+
|
269
|
+
final int W=64;
|
270
|
+
|
271
|
+
final int H=64;
|
272
|
+
|
273
|
+
int xx, yy;
|
274
|
+
|
275
|
+
int dx;
|
276
|
+
|
277
|
+
int dy;
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
void setup() {
|
282
|
+
|
283
|
+
size(384, 320);
|
284
|
+
|
285
|
+
pic=new PImage[5];
|
286
|
+
|
287
|
+
pic[0]=get(0, 0, 64, 64);
|
288
|
+
|
289
|
+
PImage img=loadImage("https://photoshopvip.net/wp-content/uploads/2014/06/BALLICONS.jpg");
|
290
|
+
|
291
|
+
for (int i=1; i<5; i++) {
|
292
|
+
|
293
|
+
pic[i]=img.get(12+77*1, 15+77*i, 64, 64);
|
294
|
+
|
295
|
+
}
|
296
|
+
|
297
|
+
picIdx=new int[5][6];
|
298
|
+
|
299
|
+
for (int i=0; i<5; i++) {
|
300
|
+
|
301
|
+
for (int j=0; j<6; j++) {
|
302
|
+
|
303
|
+
picIdx[i][j]=int(random(4)+1);
|
304
|
+
|
305
|
+
}
|
306
|
+
|
307
|
+
}
|
308
|
+
|
309
|
+
}
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
void draw() {
|
314
|
+
|
315
|
+
for (int i=0; i<5; i++) {
|
316
|
+
|
317
|
+
for (int j=0; j<6; j++) {
|
318
|
+
|
319
|
+
image(pic[picIdx[i][j]], j*64, i*64);
|
320
|
+
|
321
|
+
}
|
322
|
+
|
323
|
+
}
|
324
|
+
|
325
|
+
if (stick!=0) {
|
326
|
+
|
327
|
+
image(pic[stick], mouseX-dx, mouseY-dy);
|
328
|
+
|
329
|
+
}
|
330
|
+
|
331
|
+
}
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
void mousePressed() {
|
336
|
+
|
337
|
+
int x=mouseX/W;
|
338
|
+
|
339
|
+
int y=mouseY/H;
|
340
|
+
|
341
|
+
dx=mouseX%W;
|
342
|
+
|
343
|
+
dy=mouseY%H;
|
344
|
+
|
345
|
+
if (stick==0) {
|
346
|
+
|
347
|
+
xx=x;
|
348
|
+
|
349
|
+
yy=y;
|
350
|
+
|
351
|
+
stick=picIdx[y][x];
|
352
|
+
|
353
|
+
picIdx[y][x]=0;
|
354
|
+
|
355
|
+
} else {
|
356
|
+
|
357
|
+
picIdx[yy][xx]=picIdx[y][x];
|
358
|
+
|
359
|
+
picIdx[y][x]=stick;
|
360
|
+
|
361
|
+
stick=0;
|
362
|
+
|
363
|
+
}
|
364
|
+
|
365
|
+
}
|