質問編集履歴
1
付けたし
test
CHANGED
File without changes
|
test
CHANGED
@@ -148,6 +148,238 @@
|
|
148
148
|
|
149
149
|
}
|
150
150
|
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
class Rocket
|
158
|
+
|
159
|
+
{
|
160
|
+
|
161
|
+
public boolean sleep = true,fire=false;
|
162
|
+
|
163
|
+
private int energy,patch,length;
|
164
|
+
|
165
|
+
private int wx,hy,x,y,ox,oy,vx[],vy[];
|
166
|
+
|
167
|
+
private int t,h,red,blue,green;
|
168
|
+
|
169
|
+
private int a,b,gravity;
|
170
|
+
|
171
|
+
private int ly;
|
172
|
+
|
173
|
+
private int time;
|
174
|
+
|
175
|
+
private Random random;
|
176
|
+
|
177
|
+
private AudioClip don;
|
178
|
+
|
179
|
+
Thread launcher;
|
180
|
+
|
181
|
+
private double cosA;
|
182
|
+
|
183
|
+
private double sinA;
|
184
|
+
|
185
|
+
public Rocket(int a,int b,int g) {
|
186
|
+
|
187
|
+
wx=a;
|
188
|
+
|
189
|
+
hy=b;
|
190
|
+
|
191
|
+
gravity=g;
|
192
|
+
|
193
|
+
}
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
public void init(int e,int p,int l,long seed, int my) {
|
198
|
+
|
199
|
+
int i;
|
200
|
+
|
201
|
+
ly=my-50;
|
202
|
+
|
203
|
+
double qx,qy,qz,ux,uy,uz;
|
204
|
+
|
205
|
+
energy=e;
|
206
|
+
|
207
|
+
patch=p;
|
208
|
+
|
209
|
+
length=l;
|
210
|
+
|
211
|
+
h=0;
|
212
|
+
|
213
|
+
random=new Random(seed);
|
214
|
+
|
215
|
+
vx =new int[patch];
|
216
|
+
|
217
|
+
vy =new int[patch];
|
218
|
+
|
219
|
+
red =(int)(random.nextDouble() * 128) + 128;
|
220
|
+
|
221
|
+
blue =(int)(random.nextDouble() * 128) + 128;
|
222
|
+
|
223
|
+
green =(int)(random.nextDouble() * 128) + 128;
|
224
|
+
|
225
|
+
ox=(int)(Math.random()*wx/2)+wx/4;
|
226
|
+
|
227
|
+
oy=(int)(Math.random()*hy/2)+hy/4;
|
228
|
+
|
229
|
+
for(i=0;i<patch;++i) {
|
230
|
+
|
231
|
+
qx=Math.random();
|
232
|
+
|
233
|
+
qy=Math.random();
|
234
|
+
|
235
|
+
ux=qx-0.5;
|
236
|
+
|
237
|
+
uy=qy-0.5;
|
238
|
+
|
239
|
+
if((ux*ux+uy*uy)<0.25){
|
240
|
+
|
241
|
+
vx[i]=(int)(qx*energy)-energy/2;
|
242
|
+
|
243
|
+
vy[i]=(int)(qy*energy*7/8)-energy/8;
|
244
|
+
|
245
|
+
}else --i;
|
246
|
+
|
247
|
+
}
|
248
|
+
|
249
|
+
}
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
public void start() {
|
254
|
+
|
255
|
+
t=0;
|
256
|
+
|
257
|
+
sleep=false;
|
258
|
+
|
259
|
+
}
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
public void line(Graphics g){
|
264
|
+
|
265
|
+
if(h<=(ly-oy)){
|
266
|
+
|
267
|
+
g.setColor(new Color(0,0,0));
|
268
|
+
|
269
|
+
g.drawLine(ox,(ly-h)-3,ox,(ly-h)+5);
|
270
|
+
|
271
|
+
if (h <(ly-oy)){
|
272
|
+
|
273
|
+
g.setColor(new Color(160,180,255));
|
274
|
+
|
275
|
+
g.drawLine(ox,(ly-h),ox,(ly-h)-3);
|
276
|
+
|
277
|
+
}
|
278
|
+
|
279
|
+
}
|
280
|
+
|
281
|
+
h=h+4;
|
282
|
+
|
283
|
+
if(h>=(ly-oy)) fire=true;
|
284
|
+
|
285
|
+
else fire=false;
|
286
|
+
|
287
|
+
}
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
public synchronized void show(boolean fg,Graphics g,AudioClip don) {
|
292
|
+
|
293
|
+
if (!sleep) {
|
294
|
+
|
295
|
+
if(fg){
|
296
|
+
|
297
|
+
line(g);
|
298
|
+
|
299
|
+
if(fire){
|
300
|
+
|
301
|
+
if (t<length*4/5) {
|
302
|
+
|
303
|
+
int i,c;
|
304
|
+
|
305
|
+
int tb =6;
|
306
|
+
|
307
|
+
if(length < tb) tb =length ;
|
308
|
+
|
309
|
+
if(t == tb) don.play();
|
310
|
+
|
311
|
+
double s;
|
312
|
+
|
313
|
+
Color color;
|
314
|
+
|
315
|
+
c =(int)(random.nextDouble()*64)-32+red;
|
316
|
+
|
317
|
+
if (c >= 0 && c <256) red=c;
|
318
|
+
|
319
|
+
c =(int)(random.nextDouble()*64)-32+blue;
|
320
|
+
|
321
|
+
if (c >= 0 && c <256) blue=c;
|
322
|
+
|
323
|
+
c =(int)(random.nextDouble()*64)-32+green;
|
324
|
+
|
325
|
+
if (c >= 0 && c <256) green=c;
|
326
|
+
|
327
|
+
color = new Color(red,blue,green);
|
328
|
+
|
329
|
+
for (i=0;i<patch;++i) {
|
330
|
+
|
331
|
+
s = (double)t/100;
|
332
|
+
|
333
|
+
x = (int)(vx[i]*s);
|
334
|
+
|
335
|
+
y = (int)(vy[i]*s-gravity*s*s);
|
336
|
+
|
337
|
+
g.setColor(color);
|
338
|
+
|
339
|
+
g.drawLine(ox+x,oy-y,ox+x,oy-y);
|
340
|
+
|
341
|
+
if (t>=length/2) {
|
342
|
+
|
343
|
+
for (int j=0;j<2;++j){
|
344
|
+
|
345
|
+
s = (double)((t-length/2)*2+j)/100;
|
346
|
+
|
347
|
+
x = (int)(vx[i]*s);
|
348
|
+
|
349
|
+
y = (int)(vy[i]*s-gravity*s*s);
|
350
|
+
|
351
|
+
g.setColor(new Color(0,0,0));
|
352
|
+
|
353
|
+
g.drawLine(ox+x,oy-y,ox+x,oy-y);
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
}
|
358
|
+
|
359
|
+
}
|
360
|
+
|
361
|
+
}
|
362
|
+
|
363
|
+
++t;
|
364
|
+
|
365
|
+
}
|
366
|
+
|
367
|
+
else sleep=true;
|
368
|
+
|
369
|
+
}
|
370
|
+
|
371
|
+
}
|
372
|
+
|
373
|
+
}
|
374
|
+
|
375
|
+
}
|
376
|
+
|
377
|
+
}
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
|
382
|
+
|
151
383
|
```
|
152
384
|
|
153
385
|
|